@layer reset, base, primitives;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body, h1, h2, h3, h4, h5, h6, p, blockquote, figure, figcaption, dl, dd, ul, ol, li, pre, code, form, fieldset, legend, input, textarea, select, button {
    margin: 0;
    padding: 0;
  }

  h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
  }

  ul, ol {
    list-style: none;
  }

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

  input, textarea, select, button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    border-radius: 0;
    appearance: none;
  }

  button {
    cursor: pointer;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  table {
    border-collapse: collapse;
    border-spacing: 0;
  }

  address {
    font-style: normal;
  }

  strong, b {
    font-weight: 600;
  }

  em, i {
    font-style: italic;
  }
}

@layer base {
  :root {
    --color-porcelain: #F7F4EF;
    --color-sand: #E8DFD3;
    --color-sage: #A8B5A0;
    --color-terracotta: #C46A4A;
    --color-deep-green: #2F4A3C;
    --color-graphite: #2E2E2E;
    --color-graphite-soft: #5A5A5A;
    --color-white: #FFFFFF;

    --font-heading: "Cormorant Garamond", serif;
    --font-body: "Inter", sans-serif;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --space-9: 96px;
    --space-10: 128px;

    --container-max: 1200px;
    --container-mobile-pad: 24px;
    --container-tablet-pad: 48px;
    --container-desktop-pad: 64px;

    --radius-sharp: 0px;
    --radius-button: 4px;
    --radius-modal: 8px;

    --shadow-subtle: 0 2px 8px rgba(46, 46, 46, 0.06);

    --border-graphite-soft: 1px solid var(--color-graphite-soft);
    --border-sage: 1px solid var(--color-sage);

    --transition-fast: 150ms ease-out;

    --focus-outline: 2px solid var(--color-terracotta);
    --focus-offset: 2px;
  }

  html {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.625;
    color: var(--color-graphite);
    background-color: var(--color-porcelain);
    scroll-behavior: smooth;
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--color-porcelain);
    color: var(--color-graphite);
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-deep-green);
    line-height: 1.2;
    font-weight: 600;
  }

  h1 {
    font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
    line-height: 1.15;
    font-weight: 600;
    margin-block-end: var(--space-5);
  }

  h2 {
    font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
    line-height: 1.2;
    font-weight: 600;
    margin-block-end: var(--space-4);
  }

  h3 {
    font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.75rem);
    line-height: 1.25;
    font-weight: 500;
    margin-block-end: var(--space-4);
  }

  h4 {
    font-size: 1.375rem;
    line-height: 1.35;
    font-weight: 500;
    margin-block-end: var(--space-3);
  }

  h5 {
    font-size: 1.125rem;
    line-height: 1.4;
    font-weight: 500;
    margin-block-end: var(--space-3);
  }

  h6 {
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 500;
    margin-block-end: var(--space-2);
  }

  p {
    font-size: 1rem;
    line-height: 1.625;
    font-weight: 400;
    margin-block-end: var(--space-4);
  }

  p:last-child {
    margin-block-end: 0;
  }

  ul, ol {
    margin-block-end: var(--space-4);
    padding-inline-start: var(--space-5);
  }

  ul:last-child, ol:last-child {
    margin-block-end: 0;
  }

  ul {
    list-style: disc;
  }

  ol {
    list-style: decimal;
  }

  li {
    font-size: 1rem;
    line-height: 1.625;
  }

  blockquote {
    margin-block-end: var(--space-4);
    padding-inline-start: var(--space-5);
    border-inline-start: 2px solid var(--color-sage);
    color: var(--color-graphite-soft);
    font-style: italic;
  }

  blockquote:last-child {
    margin-block-end: 0;
  }

  figure {
    margin-block-end: var(--space-4);
  }

  figure:last-child {
    margin-block-end: 0;
  }

  figcaption {
    font-size: 0.75rem;
    line-height: 1.5;
    letter-spacing: 0.02em;
    color: var(--color-graphite-soft);
    margin-block-start: var(--space-2);
  }

  address {
    font-size: 1rem;
    line-height: 1.625;
    color: var(--color-graphite);
  }

  small {
    font-size: 0.875rem;
    line-height: 1.5;
  }

  a {
    color: var(--color-terracotta);
    transition: color var(--transition-fast);
  }

  a:hover {
    color: var(--color-deep-green);
  }

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

  button:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
    border-radius: 2px;
  }

  img {
    border-radius: var(--radius-sharp);
  }

  hr {
    border: none;
    border-top: var(--border-sage);
    margin-block: var(--space-6);
  }

  ::selection {
    background-color: var(--color-sage);
    color: var(--color-deep-green);
  }
}

@layer primitives {
  .container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-mobile-pad);
  }

  @media (min-width: 768px) {
    .container {
      padding-inline: var(--container-tablet-pad);
    }
  }

  @media (min-width: 1024px) {
    .container {
      padding-inline: var(--container-desktop-pad);
    }
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    border-radius: var(--radius-button);
    border: 1px solid transparent;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    text-align: center;
    min-height: 44px;
  }

  .btn--primary {
    background-color: var(--color-terracotta);
    color: var(--color-white);
    border-color: var(--color-terracotta);
  }

  .btn--primary:hover {
    background-color: #B45A3E;
    border-color: #B45A3E;
    color: var(--color-white);
  }

  .btn--secondary {
    background-color: var(--color-deep-green);
    color: var(--color-white);
    border-color: var(--color-deep-green);
  }

  .btn--secondary:hover {
    background-color: #263D32;
    border-color: #263D32;
    color: var(--color-white);
  }

  .btn--outline {
    background-color: transparent;
    color: var(--color-deep-green);
    border-color: var(--color-deep-green);
  }

  .btn--outline:hover {
    background-color: var(--color-deep-green);
    color: var(--color-white);
  }

  .btn--ghost {
    background-color: transparent;
    color: var(--color-terracotta);
    border-color: transparent;
  }

  .btn--ghost:hover {
    background-color: var(--color-sand);
    color: var(--color-terracotta);
  }

  .card {
    background-color: var(--color-white);
    border: var(--border-sage);
    border-radius: var(--radius-button);
    padding: var(--space-5);
    box-shadow: var(--shadow-subtle);
  }

  .card > :last-child {
    margin-block-end: 0;
  }

  .surface-sand {
    background-color: var(--color-sand);
  }

  .surface-deep-green {
    background-color: var(--color-deep-green);
    color: var(--color-white);
  }

  .surface-deep-green h1,
  .surface-deep-green h2,
  .surface-deep-green h3,
  .surface-deep-green h4,
  .surface-deep-green h5,
  .surface-deep-green h6 {
    color: var(--color-white);
  }

  .surface-deep-green a {
    color: var(--color-terracotta);
  }

  .surface-deep-green a:hover {
    color: var(--color-sage);
  }

  .surface-deep-green .card {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--color-white);
  }

  .text-body-large {
    font-size: 1.125rem;
    line-height: 1.75;
    font-weight: 400;
  }

  .text-body-small {
    font-size: 0.875rem;
    line-height: 1.5;
    font-weight: 400;
  }

  .text-caption {
    font-size: 0.75rem;
    line-height: 1.5;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--color-graphite-soft);
  }

  .text-graphite-soft {
    color: var(--color-graphite-soft);
  }

  .text-terracotta {
    color: var(--color-terracotta);
  }

  .text-deep-green {
    color: var(--color-deep-green);
  }

  .flex-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: center;
  }

  .flex-row > * {
    min-width: 0;
  }

  .flex-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .flex-column > * {
    min-width: 0;
  }

  .flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
  }

  .flex-center > * {
    min-width: 0;
  }

  .flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  .flex-between > * {
    min-width: 0;
  }

  .grid-auto {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  }

  .grid-auto > * {
    min-width: 0;
  }

  .grid-2 {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 > * {
    min-width: 0;
  }

  .grid-3 {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-3 > * {
    min-width: 0;
  }

  .grid-4 {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(4, 1fr);
  }

  .grid-4 > * {
    min-width: 0;
  }

  @media (max-width: 1023px) {
    .grid-3,
    .grid-4 {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (max-width: 767px) {
    .grid-2,
    .grid-3,
    .grid-4 {
      grid-template-columns: 1fr;
    }
  }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    z-index: 1000;
    padding: var(--space-3) var(--space-5);
    background-color: var(--color-deep-green);
    color: var(--color-white);
    border-radius: var(--radius-button);
    font-weight: 600;
    transform: translateY(-200%);
    transition: transform var(--transition-fast);
  }

  .skip-link:focus {
    transform: translateY(0);
  }
}