@layer reset, base, primitives;

@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;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
  }

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

  input, button, textarea, select {
    font: inherit;
    color: inherit;
  }

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

  ul, ol {
    list-style: none;
  }

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

  h1, h2, h3, h4, h5, h6, p, blockquote, figure, pre {
    margin-block-end: 0;
  }

  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;
  }

  fieldset {
    border: none;
  }

  textarea {
    resize: vertical;
  }
}

@layer base {
  :root {
    --color-paper: #E8E5DA;
    --color-ink: #1C221E;
    --color-sepia: #483C32;
    --color-crimson: #A63A50;
    --color-paper-light: #F2F0E8;
    --color-ink-soft: #2A322C;

    --color-text-primary: var(--color-ink);
    --color-text-secondary: var(--color-sepia);
    --color-accent: var(--color-crimson);
    --color-background: var(--color-paper);
    --color-surface-elevated: var(--color-paper-light);
    --color-surface-dark: var(--color-ink-soft);

    --color-border: color-mix(in srgb, var(--color-sepia) 20%, transparent);
    --color-divider: color-mix(in srgb, var(--color-sepia) 30%, transparent);

    --font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
    --font-body: "Source Sans 3", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;

    --text-display: clamp(2.5rem, 5vw, 4rem);
    --text-h1: clamp(2rem, 4vw, 3rem);
    --text-h2: clamp(1.5rem, 3vw, 2rem);
    --text-h3: clamp(1.25rem, 2vw, 1.5rem);
    --text-body: 1rem;
    --text-caption: 0.875rem;

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

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-xxl: 4rem;

    --container-max: 1200px;
    --container-padding: var(--space-md);
    --card-padding: 1.5rem;
    --section-spacing: var(--space-xl);

    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;

    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;

    --aspect-hero: 16 / 9;
    --aspect-card: 4 / 3;
    --aspect-thumb: 1 / 1;
  }

  html {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 100%;
    line-height: var(--leading-body);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    overflow-x: clip;
    min-height: 100vh;
    min-height: 100dvh;
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-text-primary);
    font-weight: 700;
    line-height: var(--leading-h2);
    margin-block-end: var(--space-md);
  }

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

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

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

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

  p {
    font-size: var(--text-body);
    line-height: var(--leading-body);
    color: var(--color-text-primary);
    margin-block-end: var(--space-md);
  }

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

  ul {
    list-style: disc;
  }

  ol {
    list-style: decimal;
  }

  blockquote {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: var(--text-h3);
    line-height: var(--leading-h3);
    color: var(--color-text-secondary);
    border-inline-start: 3px solid var(--color-accent);
    padding-inline-start: var(--space-md);
    margin-block-end: var(--space-lg);
  }

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

  figcaption {
    font-size: var(--text-caption);
    line-height: var(--leading-caption);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-secondary);
    margin-block-start: var(--space-sm);
  }

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

  a:hover {
    text-decoration: underline;
    color: var(--color-accent);
  }

  strong, b {
    font-weight: 700;
  }

  em, i {
    font-style: italic;
  }

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

  hr {
    border-block-start: 1px solid var(--color-divider);
    margin-block: var(--space-lg);
  }

  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  input, textarea, select, button {
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: var(--leading-body);
  }

  input, textarea, select {
    background-color: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text-primary);
    width: 100%;
  }

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

  textarea {
    min-height: 8rem;
  }

  label {
    display: block;
    font-size: var(--text-caption);
    line-height: var(--leading-caption);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary);
    margin-block-end: var(--space-xs);
  }

  ::selection {
    background-color: var(--color-accent);
    color: var(--color-paper-light);
  }

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

  h1:last-child,
  h2:last-child,
  h3:last-child,
  h4:last-child,
  h5:last-child,
  h6:last-child,
  p:last-child,
  ul:last-child,
  ol:last-child,
  blockquote:last-child,
  figure:last-child,
  hr:last-child {
    margin-block-end: 0;
  }
}

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

  .btn {
    display: inline-block;
    font-family: var(--font-body);
    font-size: var(--text-caption);
    line-height: var(--leading-caption);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--color-paper-light);
    background-color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  }

  .btn:hover {
    background-color: color-mix(in srgb, var(--color-accent) 85%, black);
    border-color: color-mix(in srgb, var(--color-accent) 85%, black);
    text-decoration: none;
    color: var(--color-paper-light);
  }

  .btn:active {
    transform: scale(0.98);
  }

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

  .btn--secondary:hover {
    background-color: var(--color-accent);
    color: var(--color-paper-light);
  }

  .card {
    background-color: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--card-padding);
    transition: transform var(--transition-medium), border-color var(--transition-medium);
  }

  .card:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent);
  }

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

  .aspect-ratio {
    position: relative;
    overflow: hidden;
    background-color: var(--color-ink-soft);
  }

  .aspect-ratio img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .aspect-ratio--hero {
    aspect-ratio: var(--aspect-hero);
  }

  .aspect-ratio--card {
    aspect-ratio: var(--aspect-card);
  }

  .aspect-ratio--thumb {
    aspect-ratio: var(--aspect-thumb);
  }

  .flex {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
  }

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

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

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

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

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

  .flex--nowrap > * {
    flex: 0 1 auto;
  }

  .flex--nowrap > .flex__grow {
    flex: 1 1 auto;
  }

  .flex > .flex__shrink {
    flex: 0 1 auto;
  }

  .flex > .flex__grow {
    flex: 1 1 auto;
  }

  .sr-only {
    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;
    inset-block-start: var(--space-sm);
    inset-inline-start: var(--space-sm);
    z-index: 1000;
    background-color: var(--color-ink);
    color: var(--color-paper-light);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transform: translateY(-200%);
    transition: transform var(--transition-fast);
  }

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