@import url("https://fonts.googleapis.com/css2?family=Alegreya+SC:wght@400;500;700;800&family=Alegreya+Sans+SC:wght@400;500;700&family=Alegreya+Sans:wght@300;400;500;700&family=Alegreya:wght@400;500;700;800&display=swap");

@layer reset, tokens, base, typography, layout, components, utilities;

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

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  blockquote,
  dl,
  dd {
    margin: 0;
  }

  img,
  picture {
    max-width: 100%;
    display: block;
  }
}

@layer tokens {
  :root {
    --paper: #f8f5ee;
    --paper-2: #fffaf0;
    --ink: #2b241d;
    --muted: #6e6559;
    --accent: #7d3d20;
    --rule: #ddd5c8;

    --font-body: "Alegreya", serif;
    --font-heading: "Alegreya", serif;
    --font-ui: "Alegreya Sans", sans-serif;
    --font-label: "Alegreya Sans SC", sans-serif;

    --page-max: 80rem;
    --text-max: 42rem;
    --gap: clamp(1rem, 3vw, 2rem);
    --radius: 0.25rem;
  }
}

@layer base {
  html {
    color-scheme: light;
  }

  body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 21px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
  }

  a {
    color: var(--accent);
    text-underline-offset: 0.15em;
  }

  a:hover {
    text-decoration-thickness: 2px;
  }

  ::selection {
    background: #ead8b8;
  }
}

@layer typography {
  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-heading);
    line-height: 1.1;
    font-weight: 700;
    text-wrap: balance;
  }

  h1 {
    font-size: clamp(2.5rem, 7vw, 4.75rem);
    letter-spacing: -0.025em;
  }

  h2 {
    font-size: clamp(1.8rem, 4vw, 2.75rem);
  }

  h3 {
    font-size: 1.5rem;
  }

  p,
  li {
    max-width: var(--text-max);
  }

  blockquote {
    max-width: var(--text-max);
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    font-size: 1.2em;
    font-style: italic;
  }

  figcaption,
  .caption {
    font-family: var(--font-ui);
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .metadata,
  .prose-note {
    font-family: var(--font-ui);
    color: var(--muted);
    font-size: 0.95rem;
  }
}

@layer layout {
  .l-page {
    max-width: var(--page-max);
    margin-inline: auto;
    padding-inline: var(--gap);
  }

  .l-text {
    max-width: var(--text-max);
  }

  .l-center {
    margin-inline: auto;
  }

  .l-stack > * + * {
    margin-top: var(--stack-gap, 1rem);
  }

  .l-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
  }

  .l-sidebar {
    display: grid;
    gap: var(--gap);
  }

  @media (min-width: 900px) {
    .l-sidebar {
      grid-template-columns: minmax(0, 1fr) 18rem;
      align-items: start;
    }
  }

  .l-cards {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr));
  }

  .l-section {
    padding-block: clamp(2rem, 6vw, 5rem);
  }
}

@layer components {
  .site-header {
    border-bottom: 1px solid var(--rule);
    background: var(--paper-2);
    padding-block: 2rem;
  }

  .site-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 8vw, 5rem);
    line-height: 1;
  }

  .site-tagline {
    font-family: var(--font-ui);
    color: var(--muted);
    max-width: 40rem;
  }

  .site-nav {
    font-family: var(--font-ui);
  }

  .site-nav a {
    text-decoration: none;
  }

  .site-nav a:hover {
    text-decoration: underline;
  }

  .label {
    display: inline-block;
    font-family: var(--font-label);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid var(--rule);
    padding: 0.15rem 0.45rem;
  }

  .card,
  .metadata-box {
    border: 1px solid var(--rule);
    background: rgba(255, 255, 255, 0.4);
    padding: 1rem;
    border-radius: var(--radius);
  }

  .work-card h2,
  .work-card h3 {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.35rem;
  }

  .document-title {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1rem;
  }

  .citation {
    font-family: var(--font-ui);
    color: var(--muted);
    font-size: 0.9rem;
  }
}

@layer utilities {
  .u-muted {
    color: var(--muted);
  }

  .u-accent {
    color: var(--accent);
  }

  .u-small {
    font-size: 0.875rem;
  }

  .u-large {
    font-size: 1.25rem;
  }

  .u-measure {
    max-width: var(--text-max);
  }

  .u-border-top {
    border-top: 1px solid var(--rule);
    padding-top: 1rem;
  }

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