@layer reset, base, primitives;

/* Reset */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

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

  body {
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
  }

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

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

  button {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
  }

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

  ul,
  ol {
    list-style: none;
  }

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

  blockquote,
  q {
    quotes: none;
  }

  blockquote::before,
  blockquote::after,
  q::before,
  q::after {
    content: "";
    content: none;
  }

  hr {
    border: none;
    border-top: 1px solid currentColor;
    opacity: 0.12;
  }

  fieldset {
    border: none;
    margin: 0;
    padding: 0;
  }

  legend {
    padding: 0;
  }
}

/* Base */
@layer base {
  :root {
    /* Colors */
    --color-charcoal-900: #2b2b2b;
    --color-charcoal-700: #4a4a4a;
    --color-ivory: #f5f0e6;
    --color-forest: #2e4a3a;
    --color-forest-hover: #1f3329;
    --color-forest-active: #16261e;
    --color-burgundy: #6b1f2a;

    /* Semantic aliases */
    --color-bg: var(--color-charcoal-900);
    --color-bg-surface: var(--color-charcoal-700);
    --color-fg: var(--color-ivory);
    --color-accent: var(--color-forest);
    --color-accent-secondary: var(--color-burgundy);
    --color-border: rgba(245, 240, 230, 0.1);
    --color-focus-ring: var(--color-forest);
    --color-text-muted: rgba(245, 240, 230, 0.72);

    /* Typography */
    --font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
      Helvetica, Arial, sans-serif;

    --text-display: 3.5rem;
    --text-h1: 2.5rem;
    --text-h2: 2rem;
    --text-h3: 1.5rem;
    --text-body: 1rem;
    --text-small: 0.875rem;

    --leading-display: 1.1;
    --leading-h1: 1.2;
    --leading-h2: 1.3;
    --leading-h3: 1.4;
    --leading-body: 1.6;
    --leading-small: 1.5;

    --weight-display: 700;
    --weight-h1: 700;
    --weight-h2: 600;
    --weight-h3: 600;
    --weight-body: 400;
    --weight-small: 400;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;
    --space-7: 64px;
    --space-8: 96px;

    /* Containers */
    --container-max: 1200px;
    --gutter-mobile: 24px;
    --gutter-tablet: 32px;
    --gutter-desktop: 48px;
    --section-padding-mobile: 48px;
    --section-padding-tablet: 64px;
    --section-padding-desktop: 96px;
    --card-padding: 24px;

    /* Surfaces */
    --surface-bg: var(--color-charcoal-700);
    --surface-border: var(--color-border);
    --surface-shadow: 0 2px 8px rgba(0, 0, 0, 0.18),
      0 8px 24px rgba(0, 0, 0, 0.12);
    --surface-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.22),
      0 12px 32px rgba(0, 0, 0, 0.16);

    /* Corners */
    --radius-small: 4px;
    --radius-medium: 8px;
    --radius-large: 16px;
    --radius-pill: 999px;

    /* Transitions */
    --transition-color: 200ms ease;
    --transition-transform: 300ms ease;
    --transition-shadow: 300ms ease;
  }

  html {
    font-family: var(--font-body);
    font-size: var(--text-body);
    font-weight: var(--weight-body);
    line-height: var(--leading-body);
    color: var(--color-fg);
    background-color: var(--color-bg);
  }

  body {
    font-family: var(--font-body);
    font-size: var(--text-body);
    font-weight: var(--weight-body);
    line-height: var(--leading-body);
    color: var(--color-fg);
    background-color: var(--color-bg);
    overflow-x: hidden;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--font-heading);
    color: var(--color-fg);
    overflow-wrap: break-word;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
    font-weight: var(--weight-h1);
    margin-block-end: var(--space-4);
  }

  h2 {
    font-size: var(--text-h2);
    line-height: var(--leading-h2);
    font-weight: var(--weight-h2);
    margin-block-end: var(--space-4);
  }

  h3 {
    font-size: var(--text-h3);
    line-height: var(--leading-h3);
    font-weight: var(--weight-h3);
    margin-block-end: var(--space-3);
  }

  h4,
  h5,
  h6 {
    font-size: var(--text-body);
    line-height: var(--leading-body);
    font-weight: var(--weight-h2);
    margin-block-end: var(--space-3);
  }

  p {
    font-size: var(--text-body);
    line-height: var(--leading-body);
    margin-block-end: var(--space-4);
    overflow-wrap: break-word;
  }

  small {
    font-size: var(--text-small);
    line-height: var(--leading-small);
    font-weight: var(--weight-small);
  }

  a {
    color: var(--color-accent);
    transition: color var(--transition-color);
  }

  a:hover {
    color: var(--color-forest-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
  }

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

  strong,
  b {
    font-weight: 600;
  }

  em,
  i {
    font-style: italic;
  }

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

  ul {
    list-style: disc;
  }

  ol {
    list-style: decimal;
  }

  blockquote {
    margin-block-end: var(--space-4);
    padding-inline-start: var(--space-4);
    border-inline-start: 3px solid var(--color-accent);
    color: var(--color-text-muted);
  }

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

  figcaption {
    font-size: var(--text-small);
    line-height: var(--leading-small);
    color: var(--color-text-muted);
    margin-block-start: var(--space-2);
  }

  hr {
    margin-block: var(--space-6);
    border-color: var(--color-border);
  }

  code,
  pre,
  kbd,
  samp {
    font-family: "SF Mono", "Cascadia Code", Consolas, "Liberation Mono",
      monospace;
    font-size: 0.9em;
  }

  pre {
    background: var(--color-charcoal-700);
    color: var(--color-ivory);
    padding: var(--space-3);
    border-radius: var(--radius-medium);
    overflow-x: auto;
    margin-block-end: var(--space-4);
  }

  code {
    background: rgba(245, 240, 230, 0.08);
    padding: 2px 6px;
    border-radius: var(--radius-small);
  }

  mark {
    background: var(--color-burgundy);
    color: var(--color-ivory);
    padding: 2px 4px;
    border-radius: 2px;
  }

  abbr[title] {
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: help;
  }

  /* Forms */
  label {
    display: block;
    font-size: var(--text-small);
    font-weight: 500;
    margin-block-end: var(--space-2);
    color: var(--color-fg);
  }

  input,
  textarea,
  select {
    display: block;
    width: 100%;
    padding: var(--space-3);
    background-color: var(--color-charcoal-700);
    color: var(--color-ivory);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    transition: border-color var(--transition-color),
      box-shadow var(--transition-color);
  }

  input::placeholder,
  textarea::placeholder {
    color: rgba(245, 240, 230, 0.5);
  }

  input:focus,
  textarea:focus,
  select:focus {
    border-color: var(--color-forest);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
    outline: none;
  }

  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 1px;
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }

  select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23F5F0E6' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-inline-end: var(--space-6);
  }

  input[type="checkbox"],
  input[type="radio"] {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    padding: 0;
    margin-inline-end: var(--space-2);
    vertical-align: middle;
    accent-color: var(--color-forest);
  }

  input[type="checkbox"] + label,
  input[type="radio"] + label {
    display: inline-block;
    margin-block-end: 0;
  }

  input[type="file"] {
    padding: var(--space-2);
    background: transparent;
    border: 1px dashed var(--color-border);
  }

  input[type="range"] {
    padding: 0;
    background: transparent;
    border: none;
    accent-color: var(--color-forest);
  }

  input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
  }

  input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
  }

  input[type="number"]::-webkit-inner-spin-button,
  input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="week"] {
    -webkit-appearance: none;
    appearance: none;
  }

  input[type="color"] {
    padding: 2px;
    height: 44px;
    cursor: pointer;
  }

  fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);
    padding: var(--space-4);
    margin-block-end: var(--space-4);
  }

  legend {
    font-family: var(--font-heading);
    font-weight: var(--weight-h2);
    padding-inline: var(--space-2);
  }

  /* Media */
  img {
    border-radius: var(--radius-medium);
  }

  video {
    border-radius: var(--radius-medium);
    background: #000;
  }

  /* Focus visibility for all interactive elements */
  :focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
  }

  /* Selection */
  ::selection {
    background: var(--color-burgundy);
    color: var(--color-ivory);
  }

  /* Scrollbar */
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  ::-webkit-scrollbar-track {
    background: var(--color-charcoal-900);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--color-charcoal-700);
    border-radius: var(--radius-pill);
    border: 2px solid var(--color-charcoal-900);
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
  }
}

/* Primitives */
@layer primitives {
  /* Container */
  .container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--gutter-mobile);
  }

  /* Section */
  .section {
    padding-block: var(--section-padding-mobile);
  }

  /* Surface / Card */
  .surface {
    background-color: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-medium);
    box-shadow: var(--surface-shadow);
    padding: var(--card-padding);
  }

  .surface--large {
    border-radius: var(--radius-large);
  }

  .surface--hover {
    transition: transform var(--transition-transform),
      box-shadow var(--transition-shadow);
  }

  .surface--hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--surface-shadow-hover);
  }

  /* Button */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background-color: var(--color-forest);
    color: var(--color-ivory);
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    font-family: var(--font-body);
    font-size: var(--text-body);
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--transition-color),
      border-color var(--transition-color), color var(--transition-color),
      transform var(--transition-transform);
    -webkit-user-select: none;
    user-select: none;
  }

  .btn:hover {
    background-color: var(--color-forest-hover);
    color: var(--color-ivory);
    text-decoration: none;
  }

  .btn:active {
    background-color: var(--color-forest-active);
    transform: scale(0.98);
  }

  .btn:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
  }

  .btn--secondary {
    background-color: transparent;
    border-color: var(--color-forest);
    color: var(--color-forest);
  }

  .btn--secondary:hover {
    background-color: var(--color-forest);
    color: var(--color-ivory);
  }

  .btn--secondary:active {
    background-color: var(--color-forest-hover);
  }

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

  .btn--ghost:hover {
    background-color: rgba(245, 240, 230, 0.08);
    border-color: rgba(245, 240, 230, 0.2);
    color: var(--color-fg);
  }

  .btn--ghost:active {
    background-color: rgba(245, 240, 230, 0.14);
  }

  .btn--burgundy {
    background-color: var(--color-burgundy);
  }

  .btn--burgundy:hover {
    background-color: #571822;
  }

  .btn--burgundy:active {
    background-color: #45131b;
  }

  .btn--small {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  .btn--large {
    padding: var(--space-4) var(--space-5);
    font-size: 1.125rem;
  }

  .btn--pill {
    border-radius: var(--radius-pill);
  }

  .btn--block {
    display: flex;
    width: 100%;
  }

  /* Badge / Tag */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background-color: var(--color-burgundy);
    color: var(--color-ivory);
    border-radius: var(--radius-pill);
    font-size: var(--text-small);
    font-weight: 500;
    line-height: var(--leading-small);
    white-space: nowrap;
  }

  .badge--forest {
    background-color: var(--color-forest);
  }

  .badge--outline {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-fg);
  }

  /* Overline */
  .overline {
    display: block;
    font-size: var(--text-small);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-forest);
    margin-block-end: var(--space-2);
  }

  /* Link */
  .link {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color var(--transition-color);
  }

  .link:hover {
    color: var(--color-forest-hover);
  }

  /* Visually hidden */
  .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 */
  .skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    z-index: 9999;
    padding: var(--space-3) var(--space-4);
    background-color: var(--color-forest);
    color: var(--color-ivory);
    border-radius: var(--radius-small);
    font-weight: 500;
    transition: top var(--transition-transform);
  }

  .skip-link:focus {
    top: var(--space-4);
    color: var(--color-ivory);
    text-decoration: none;
  }

  /* Flex utilities */
  .flex {
    display: flex;
    min-width: 0;
  }

  .flex--wrap {
    flex-wrap: wrap;
  }

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

  .flex--center {
    align-items: center;
    justify-content: center;
  }

  .flex--between {
    align-items: center;
    justify-content: space-between;
  }

  .flex--start {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .flex--end {
    align-items: flex-end;
    justify-content: flex-end;
  }

  .flex--gap-1 {
    gap: var(--space-1);
  }

  .flex--gap-2 {
    gap: var(--space-2);
  }

  .flex--gap-3 {
    gap: var(--space-3);
  }

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

  .flex--gap-5 {
    gap: var(--space-5);
  }

  .flex--gap-6 {
    gap: var(--space-6);
  }

  .flex__item {
    min-width: 0;
    flex-shrink: 0;
  }

  .flex__item--grow {
    flex-grow: 1;
    flex-shrink: 1;
  }

  /* Spacing utilities */
  .mt-1 {
    margin-block-start: var(--space-1);
  }
  .mt-2 {
    margin-block-start: var(--space-2);
  }
  .mt-3 {
    margin-block-start: var(--space-3);
  }
  .mt-4 {
    margin-block-start: var(--space-4);
  }
  .mt-5 {
    margin-block-start: var(--space-5);
  }
  .mt-6 {
    margin-block-start: var(--space-6);
  }
  .mt-7 {
    margin-block-start: var(--space-7);
  }
  .mt-8 {
    margin-block-start: var(--space-8);
  }

  .mb-1 {
    margin-block-end: var(--space-1);
  }
  .mb-2 {
    margin-block-end: var(--space-2);
  }
  .mb-3 {
    margin-block-end: var(--space-3);
  }
  .mb-4 {
    margin-block-end: var(--space-4);
  }
  .mb-5 {
    margin-block-end: var(--space-5);
  }
  .mb-6 {
    margin-block-end: var(--space-6);
  }
  .mb-7 {
    margin-block-end: var(--space-7);
  }
  .mb-8 {
    margin-block-end: var(--space-8);
  }

  /* Text utilities */
  .text-center {
    text-align: center;
  }

  .text-left {
    text-align: left;
  }

  .text-right {
    text-align: right;
  }

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

  .text-small {
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  .text-display {
    font-family: var(--font-heading);
    font-size: var(--text-display);
    line-height: var(--leading-display);
    font-weight: var(--weight-display);
  }

  .text-h1 {
    font-family: var(--font-heading);
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
    font-weight: var(--weight-h1);
  }

  .text-h2 {
    font-family: var(--font-heading);
    font-size: var(--text-h2);
    line-height: var(--leading-h2);
    font-weight: var(--weight-h2);
  }

  .text-h3 {
    font-family: var(--font-heading);
    font-size: var(--text-h3);
    line-height: var(--leading-h3);
    font-weight: var(--weight-h3);
  }

  /* Image treatment */
  .img--rounded {
    border-radius: var(--radius-medium);
  }

  .img--rounded-lg {
    border-radius: var(--radius-large);
  }

  .img--cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .img--contain {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  /* Last child spacing reset */
  .surface > :last-child,
  .card > :last-child,
  .panel > :last-child,
  .content-group > :last-child {
    margin-block-end: 0;
  }

  /* Responsive heading scale */
  @media (max-width: 1024px) {
    :root {
      --text-display: 3rem;
      --text-h1: 2.25rem;
      --text-h2: 1.875rem;
      --text-h3: 1.375rem;
    }
  }

  @media (max-width: 768px) {
    :root {
      --text-display: 2.5rem;
      --text-h1: 2rem;
      --text-h2: 1.75rem;
      --text-h3: 1.25rem;
    }
  }

  @media (max-width: 640px) {
    :root {
      --text-display: 2rem;
      --text-h1: 1.75rem;
      --text-h2: 1.5rem;
      --text-h3: 1.25rem;
    }
  }

  /* Responsive spacing */
  @media (max-width: 768px) {
    :root {
      --section-padding-mobile: 48px;
      --section-padding-tablet: 48px;
      --section-padding-desktop: 48px;
    }

    .section {
      padding-block: var(--section-padding-mobile);
    }
  }

  @media (min-width: 769px) and (max-width: 1024px) {
    .section {
      padding-block: var(--section-padding-tablet);
    }
  }

  @media (min-width: 1025px) {
    .section {
      padding-block: var(--section-padding-desktop);
    }
  }

  /* Responsive container gutters */
  @media (min-width: 641px) and (max-width: 1024px) {
    .container {
      padding-inline: var(--gutter-tablet);
    }
  }

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