@import '@fontsource-variable/lora/index.css';
@import '@fontsource-variable/work-sans/index.css';

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ──────────────────────────────────────────────────────────────────────────
   Marginalia — newsletter landing.
   Light-default. Cream paper #FAF7F2. Oxblood ink #881337. No dark toggle.
   Lora (display/serif) + Work Sans (body/UI).
   ────────────────────────────────────────────────────────────────────────── */

@layer base {
  :root {
    color-scheme: light;
    /* Surfaces — warm cream, slightly lifted card surface, sub-band tone. */
    --color-bg:           #FAF7F2;  /* paper */
    --color-surface:      #F4EFE6;  /* warmer card / band */
    --color-surface-2:    #ECE5D6;  /* deeper band */
    /* Text */
    --color-text:         #2A1F1F;  /* near-black ink, warm */
    --color-text-muted:   #5C4D4D;  /* warm muted, AA on bg at 7.5:1 */
    --color-text-subtle:  #7A6A6A;
    /* Accent — Tailwind rose-900 oxblood. AA on cream at 9.4:1 */
    --color-accent:       #881337;
    --color-accent-hover: #6F0F2D;  /* deeper on hover */
    --color-accent-deep:  #5A0A24;
    --color-on-accent:    #FAF7F2;
    /* Lines */
    --color-border:       #D9CDB7;  /* warm, low-contrast */
    --color-border-strong:#B6A689;
  }

  html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    background-color: var(--color-bg);
    color: var(--color-text);
  }
  body {
    font-family: 'Work Sans Variable', 'Work Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-feature-settings: 'kern', 'liga', 'onum';
    background-color: var(--color-bg);
    color: var(--color-text);
  }
  ::selection {
    background-color: var(--color-accent);
    color: var(--color-on-accent);
  }
  *:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 0.125rem;
  }
}

@layer components {
  .container-x {
    @apply mx-auto w-full max-w-7xl px-5 sm:px-8 lg:px-10;
  }
  /* Narrow editorial column for prose-only sections. */
  .container-narrow {
    @apply mx-auto w-full max-w-column px-5 sm:px-6;
  }

  /* Eyebrow — Work Sans uppercase tracking, oxblood. */
  .label-eyebrow {
    font-family: 'Work Sans Variable', 'Work Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--color-accent);
  }

  /* Buttons */
  .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    font-family: 'Work Sans Variable', sans-serif;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.7rem 1.25rem;
    border-radius: 0.25rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
    white-space: nowrap;
    min-height: 44px;
    letter-spacing: 0.005em;
  }
  .btn-primary:hover {
    background-color: var(--color-accent-hover);
  }

  .btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: transparent;
    color: var(--color-text);
    font-family: 'Work Sans Variable', sans-serif;
    font-weight: 500;
    font-size: 0.9375rem;
    padding: 0.7rem 1.25rem;
    border-radius: 0.25rem;
    border: 1px solid var(--color-border-strong);
    transition: border-color 0.12s ease, background-color 0.12s ease;
    min-height: 44px;
  }
  .btn-ghost:hover {
    border-color: var(--color-text);
    background-color: var(--color-surface);
  }

  /* Subscribe form — inline email + submit, paper-styled. */
  .subscribe-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 28rem;
  }
  @media (min-width: 480px) {
    .subscribe-form {
      flex-direction: row;
    }
  }
  .subscribe-form input[type='email'] {
    flex: 1;
    background-color: #FFFEFB;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.25rem;
    padding: 0.7rem 0.875rem;
    font-family: 'Work Sans Variable', sans-serif;
    font-size: 1rem;
    color: var(--color-text);
    min-height: 44px;
    /* Native email validity bubble matches paper tone. */
  }
  .subscribe-form input[type='email']:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
    border-color: var(--color-accent);
  }
  .subscribe-form input[type='email']::placeholder {
    color: var(--color-text-subtle);
  }
  .subscribe-form button[type='submit'] {
    @apply btn-primary;
    flex-shrink: 0;
  }

  /* Hairline */
  .hairline { border-color: var(--color-border); }

  /* Issue card — past-issue grid item */
  .issue-card {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    padding: 1.5rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.15s ease, transform 0.15s ease;
    text-decoration: none;
    color: inherit;
    height: 100%;
  }
  .issue-card:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
  }
  .issue-card .issue-meta {
    font-family: 'Work Sans Variable', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-text-muted);
  }
  .issue-card .issue-title {
    font-family: 'Lora Variable', Lora, serif;
    font-weight: 600;
    font-size: 1.5rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--color-text);
    /* Decorative drop cap — first letter only, CSS-only. */
  }
  .issue-card .issue-title::first-letter {
    color: var(--color-accent);
  }
  .issue-card .issue-teaser {
    font-family: 'Lora Variable', Lora, serif;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--color-text);
  }
  .issue-card .issue-link {
    margin-top: auto;
    padding-top: 0.5rem;
    font-family: 'Work Sans Variable', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-accent);
  }

  /* Issue counter band — sub-band with halftone dot-grid texture. */
  .counter-band {
    background-color: var(--color-surface);
    /* Halftone dot-grid (oxblood at low alpha) — pure CSS, no image. */
    background-image:
      radial-gradient(circle, rgba(136, 19, 55, 0.10) 1px, transparent 1.2px);
    background-size: 18px 18px;
    background-position: 0 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }
  .counter-divider {
    color: var(--color-border-strong);
  }

  /* Pull quotes — Lora italic, oxblood rule. */
  .pull-quote {
    font-family: 'Lora Variable', Lora, serif;
    font-style: italic;
    font-size: 1.25rem;
    line-height: 1.55;
    color: var(--color-text);
    border-left: 2px solid var(--color-accent);
    padding-left: 1.25rem;
  }
  .pull-quote-attr {
    font-family: 'Work Sans Variable', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-text-muted);
    margin-top: 0.875rem;
    display: block;
  }

  /* Display headline — Lora, generous tracking-tight. */
  .display-h1 {
    font-family: 'Lora Variable', Lora, serif;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.05;
  }
  .display-h2 {
    font-family: 'Lora Variable', Lora, serif;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.15;
  }

  /* Avatar — geometric SVG monogram, no photo */
  .avatar-monogram {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 9999px;
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    font-family: 'Lora Variable', Lora, serif;
    font-weight: 600;
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  /* Form-success / fallback states */
  .form-success {
    color: var(--color-accent);
    font-weight: 600;
  }
}

@layer utilities {
  .text-balance { text-wrap: balance; }
  .text-pretty  { text-wrap: pretty; }
  .text-accent  { color: var(--color-accent); }
  .text-muted   { color: var(--color-text-muted); }
  .border-accent{ border-color: var(--color-accent); }
  .bg-paper     { background-color: var(--color-bg); }
  .bg-warm      { background-color: var(--color-surface); }
}
