/* ============================================================
   Flickwick Design System — Cream paper tokens
   ============================================================
   Applies to marketing + app chrome.
   The flip-book reader paints its own cream pages on top.
   ============================================================ */

/* ── FONTS ─────────────────────────────────────────────────── */
/* Lora — body (warm readable serif, storybook feel) */
/* Crimson Pro — display/hero (softer serif, storybook chapter-title feel) */
/* DM Mono — utility text (timestamps, metadata only) */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* Typography */
  --font-sans: "Lora", Georgia, serif;
  --font-serif: "Crimson Pro", Georgia, serif;
  --font-mono: "DM Mono", "JetBrains Mono", ui-monospace, monospace;
  --font-utility: "Lora", Georgia, serif;

  /* Colors — cream paper, warm ink */
  --color-background: #F7F1E6;
  --color-background-muted: #EFE7D8;
  --color-foreground: #2B2620;
  --color-foreground-muted: rgba(43, 38, 32, 0.68);   /* 5.0:1 on cream — the floor for any text that carries meaning */
  --color-foreground-subtle: rgba(43, 38, 32, 0.45);  /* 2.6:1 — decoration only: rules, placeholders, the "+" on a summary. Never a label, helper or eyebrow (MAC-376) */
  --color-border: rgba(43, 38, 32, 0.10);

  /* Accent palette — deeper so they hold on cream */
  --color-forest: #3F6B4C;   /* 5.4:1 on cream — fine as text */
  --color-dijon: #B8862A;    /* 2.6:1 on cream — fills, borders and large display type only */
  --color-dijon-ink: #6A4D16; /* 6.9:1 on cream, 6.2:1 on its own tint — the dijon to WRITE with (MAC-376) */
  --color-walnut: #8B5E3C;   /* 4.9:1 */
  --color-error: #A63636;    /* 5.7:1 — the red for error text; #c44040 was 4.0:1 */

  /* Accent tints */
  --color-forest-tint: rgba(63, 107, 76, 0.10);
  --color-dijon-tint: rgba(184, 134, 42, 0.12);
  --color-walnut-tint: rgba(139, 94, 60, 0.10);

  /* Radii — softer edges */
  --radius-sm: 0.5rem;    /* 8px */
  --radius-md: 0.625rem;  /* 10px */
  --radius-lg: 0.75rem;   /* 12px */
}

/* ── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.75;
  background: var(--color-background);
  color: var(--color-foreground);
}

/* ── TYPOGRAPHY UTILITIES ──────────────────────────────────── */

/* Signature section eyebrow: utility Lora, 12px, uppercase, tracked */
.eyebrow {
  font-family: var(--font-utility);
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-foreground-muted);
  line-height: 1.4;
}

/* Mono utility text — for numbers, dates, status, metadata, table headers */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Body muted text */
.text-muted {
  color: var(--color-foreground-muted);
}

.text-subtle {
  color: var(--color-foreground-subtle);
}

/* ── FOCUS (MAC-376) ───────────────────────────────────────── */
/* One ring for everything a keyboard can land on. :where() keeps the
   specificity at zero, so a page can still draw its own state on top;
   text fields keep their border change instead of a second outline. */
:where(a, button, select, summary, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--color-forest);
  outline-offset: 2px;
}
:where(input, textarea):focus-visible {
  outline: 2px solid var(--color-forest);
  outline-offset: 1px;
}

/* ── BUTTONS ───────────────────────────────────────────────── */

/* Primary: bg-foreground text-background, 36px tall, rounded-sm */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  height: 36px;
  padding: 0 1.25rem;
  background: var(--color-foreground);
  color: var(--color-background);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Ghost / outline button */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  height: 36px;
  padding: 0 1.25rem;
  background: transparent;
  color: var(--color-foreground-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.btn-ghost:hover {
  color: var(--color-foreground);
  border-color: var(--color-border);
}
.btn-ghost:active { transform: scale(0.98); }

/* Small button (inline actions) */
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  height: 30px;
  padding: 0 0.85rem;
  background: transparent;
  color: var(--color-foreground-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.btn-sm:hover {
  color: var(--color-foreground);
  border-color: var(--color-border);
}
.btn-sm.active {
  background: var(--color-foreground);
  color: var(--color-background);
  border-color: var(--color-foreground);
}

/* ── STATUS PILLS ──────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}
.pill-forest {
  color: var(--color-forest);
  background: var(--color-forest-tint);
}
.pill-dijon {
  color: var(--color-dijon-ink);
  background: var(--color-dijon-tint);
}
.pill-walnut {
  color: var(--color-walnut);
  background: var(--color-walnut-tint);
}

/* ── TOOLTIPS ──────────────────────────────────────────────── */
/* A small "?" that explains a heading or control on hover or keyboard
   focus. Pure CSS: the text lives in data-tip, so it is also read out as
   the aria-label the markup gives it. */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 0.35rem;
  border-radius: 9999px;
  border: 0.5px solid var(--color-border);
  color: var(--color-foreground-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
  position: relative;
  text-transform: none;
  letter-spacing: 0;
}
.tip:hover, .tip:focus {
  color: var(--color-forest);
  border-color: var(--color-forest);
  outline: none;
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 260px;
  padding: 0.55rem 0.7rem;
  background: var(--color-foreground);
  color: var(--color-background);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  border-radius: var(--radius-sm);
  display: none;
  z-index: 30;
}
.tip:hover::after, .tip:focus::after {
  display: block;
  transform: translateX(-50%) translateY(0);
}
/* A phone has no hover: a tap focuses the "?" (it has tabindex) and the
   tip shows until the next tap. Anchor it to the left so it stays on
   screen at 375px. */
@media (max-width: 560px) {
  .tip::after { max-width: min(260px, 78vw); }
}

/* ── CARDS ─────────────────────────────────────────────────── */
/* Default: no border, no shadow, no fill. Whitespace separates. */
/* If grouping is ambiguous: hairline OR muted bg — never both. */
.card {
  border-radius: var(--radius-lg);
}
.card-hairline {
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.card-muted {
  background: var(--color-background-muted);
  border-radius: var(--radius-lg);
}

/* ── INPUTS ────────────────────────────────────────────────── */
.input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem;
  background: var(--color-background);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus {
  border-color: var(--color-forest);
}
.input::placeholder {
  color: var(--color-foreground-subtle);
}

/* Textarea */
.textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--color-background);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  resize: vertical;
  line-height: 1.55;
  transition: border-color 0.15s;
}
.textarea:focus {
  border-color: var(--color-forest);
}
.textarea::placeholder {
  color: var(--color-foreground-subtle);
}

/* ── NAV ───────────────────────────────────────────────────── */
.nav,
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-bottom: 0.5px solid var(--color-border);
  background: rgba(247, 241, 230, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-logo {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 18px;
  color: var(--color-foreground);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.app-nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.app-nav-links a {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-foreground-muted);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
}
.app-nav-links a:hover,
.app-nav-links a.active {
  color: var(--color-foreground);
}
.app-nav-links a.active {
  background: var(--color-forest-tint);
  color: var(--color-forest);
}

.app-tabbar {
  display: none;
}

@media (max-width: 720px) {
  .app-nav-links { display: none; }
  .app-nav .nav-right .btn-sm { display: none; }
  body.has-app-chrome { padding-bottom: 4.75rem; }

  .app-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: rgba(247, 241, 230, 0.96);
    border-top: 0.5px solid var(--color-border);
    padding: 0.45rem 0.4rem calc(0.45rem + env(safe-area-inset-bottom));
  }
  .app-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--color-foreground-muted);
    text-decoration: none;
    padding: 0.35rem 0.2rem;
    min-height: 44px;
    border-radius: var(--radius-sm);
  }
  .app-tabbar a.active {
    color: var(--color-forest);
    background: var(--color-forest-tint);
  }
}

/* Marketing topnav (landing, pricing, blog) */
.topnav {
  background: rgba(247, 241, 230, 0.9);
}

/* ── HAIRLINE DIVIDER ──────────────────────────────────────── */
.divider {
  height: 0.5px;
  background: var(--color-border);
}

/* ── LOADING SPINNER ───────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--color-border);
  border-top-color: var(--color-forest);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MODAL / OVERLAY ───────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal-sheet {
  background: var(--color-background);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
}

/* ── BOTTOM SHEET ──────────────────────────────────────────── */
.bottom-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
}
.bottom-sheet-overlay.active { display: flex; }

.bottom-sheet {
  background: var(--color-background);
  border-top: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  padding: 1.25rem 1.5rem 2rem;
  max-height: 90vh;
  overflow-y: auto;
  animation: sheetUp 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes sheetUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.sheet-handle {
  width: 32px;
  height: 3px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}

/* ── LINK STYLE ────────────────────────────────────────────── */
a {
  color: inherit;
  text-decoration-color: var(--color-border);
  text-underline-offset: 3px;
}

/* ── PAPER GRAIN NOISE OVERLAY ─────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}
