/* ==========================================================================
   TH Heritage Cabinetry Base Styles
   Reset, typography, global elements
   ========================================================================== */

/* ── Modern Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body-md-size);
  font-weight: var(--text-body-md-weight);
  line-height: var(--text-body-md-line);
  color: var(--color-on-surface);
  background-color: var(--color-neutral);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-primary);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-headline-lg-size);
  font-weight: var(--text-headline-lg-weight);
  line-height: var(--text-headline-lg-line);
  letter-spacing: var(--text-headline-lg-tracking);
}

h2 {
  font-size: var(--text-headline-md-size);
  font-weight: var(--text-headline-md-weight);
  line-height: var(--text-headline-md-line);
  letter-spacing: var(--text-headline-md-tracking);
}

h3 {
  font-size: var(--text-headline-sm-size);
  font-weight: var(--text-headline-sm-weight);
  line-height: var(--text-headline-sm-line);
}

h4 {
  font-family: var(--font-body);
  font-size: var(--text-body-lg-size);
  font-weight: 600;
  line-height: var(--text-body-lg-line);
}

p {
  font-size: var(--text-body-md-size);
  line-height: var(--text-body-md-line);
  color: var(--color-on-surface-variant);
  max-width: 65ch;
}

p.lead {
  font-size: var(--text-body-lg-size);
  line-height: var(--text-body-lg-line);
}

small, .text-sm {
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line);
}

.text-label {
  font-size: var(--text-label-lg-size);
  font-weight: var(--text-label-lg-weight);
  letter-spacing: var(--text-label-lg-tracking);
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
}

.text-label-sm {
  font-size: var(--text-label-sm-size);
  font-weight: var(--text-label-sm-weight);
  letter-spacing: var(--text-label-sm-tracking);
  text-transform: uppercase;
}

.display {
  font-family: var(--font-display);
  font-size: var(--text-headline-display-size);
  font-weight: var(--text-headline-display-weight);
  line-height: var(--text-headline-display-line);
  letter-spacing: var(--text-headline-display-tracking);
}

/* ── Links ── */
a {
  color: var(--color-tertiary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #7C3610;
}

a:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Images ── */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  object-fit: cover;
}

/* ── Lists ── */
ul, ol {
  list-style: none;
}

/* ── Buttons & Interactive ── */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ── Selection ── */
::selection {
  background-color: var(--color-tertiary-container);
  color: var(--color-on-tertiary-container);
}

/* ── Scrollbar (Webkit) ── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface-container);
}

::-webkit-scrollbar-thumb {
  background: var(--color-outline);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* ── Layout Utilities ── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section {
  padding: var(--space-section) 0;
}

.section-alt {
  background-color: var(--color-surface-dim);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.gap-2xl { gap: var(--space-2xl); }

.grid {
  display: grid;
  gap: var(--space-gutter);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Visibility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.hidden { display: none; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  h1 {
    font-size: 36px;
  }

  h2 {
    font-size: 28px;
  }

  .display {
    font-size: 48px;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-md);
  }

  .section {
    padding: var(--space-3xl) 0;
  }

  h1 {
    font-size: 32px;
  }

  .display {
    font-size: 40px;
  }

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 375px) {
  html {
    font-size: 15px;
  }
}
