/* Papel — Werpa's visual system, shared with the app (theme/palettes.ts, theme/typography.ts).
   Light: Papel. Dark: Lampara (follows prefers-color-scheme).
   Every page links this file; page-level <style> blocks use these tokens only. */

@font-face { font-family: 'Switzer'; src: url('/assets/fonts/Switzer-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Switzer'; src: url('/assets/fonts/Switzer-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Switzer'; src: url('/assets/fonts/Switzer-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: light dark;

  /* Papel (light) */
  --p-bg: #FBF6EC;
  --p-surface: #FFFFFF;
  --p-surface-sunk: #F4ECDC;
  --p-text: #1F2A44;
  --p-text-muted: #5B6478;
  --p-text-subtle: #6A6F7C;
  --p-primary: #2F5BEA;
  --p-primary-end: #2448C9;
  --p-on-primary: #FFFFFF;
  --p-blue-light: #DCE5FD;
  --p-accent: #C93A30;
  --p-gold: #F2B33D;
  --p-gold-light: #FBEBC8;
  --p-on-gold: #2A2111;
  --p-success: #2F9E5F;
  --p-success-fill: #1B7A43;
  --p-on-success: #FFFFFF;
  --p-hairline: #E6DCC8;
  --p-border: rgba(80, 60, 20, 0.08);
  --p-gray-100: #ECE3D0;
  --p-gray-300: #D4C8B0;
  --p-shadow: 0 2px 6px rgba(80, 60, 20, 0.06), 0 1px 2px rgba(80, 60, 20, 0.04);
  --p-shadow-lift: 0 8px 22px rgba(80, 60, 20, 0.10), 0 2px 4px rgba(80, 60, 20, 0.05);

  /* Crossword cells */
  --p-cell-bg: #FFFFFF;
  --p-cell-border: #E6DCC8;
  --p-cell-blocked: #ECE3D0;
  --p-cell-word: #DCE5FD;
  --p-cell-text: #1F2A44;
  --p-cell-accent: #2F5BEA;

  /* Type */
  --p-font-display: 'Outfit', ui-rounded, system-ui, sans-serif;
  --p-font-ui: 'Switzer', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --p-font-read: 'Literata', Georgia, 'Times New Roman', serif;

  /* Space and shape */
  --p-xs: 4px; --p-sm: 8px; --p-md: 14px; --p-lg: 18px; --p-xl: 26px; --p-xxl: 34px; --p-xxxl: 50px;
  --p-r-sm: 8px; --p-r-md: 10px; --p-r-lg: 12px; --p-r-xl: 16px; --p-r-round: 999px;
  --p-max: 1120px;
  --p-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Lampara (dark) */
    --p-bg: #211E1A;
    --p-surface: #2C2823;
    --p-surface-sunk: #26221E;
    --p-text: #F3EBDD;
    --p-text-muted: #C4B9A6;
    --p-text-subtle: #A89D8A;
    --p-primary: #86A0FF;
    --p-primary-end: #6F8AF0;
    --p-on-primary: #10162E;
    --p-blue-light: #33395A;
    --p-accent: #FF7F6E;
    --p-gold: #F2B33D;
    --p-gold-light: #3B3122;
    --p-on-gold: #2A2111;
    --p-success: #5CC98A;
    --p-success-fill: #5CC98A;
    --p-on-success: #14261B;
    --p-hairline: #3E372E;
    --p-border: rgba(255, 240, 210, 0.08);
    --p-gray-100: #36312A;
    --p-gray-300: #4A4339;
    --p-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    --p-shadow-lift: 0 10px 24px rgba(0, 0, 0, 0.38);

    --p-cell-bg: #EFE6D4;
    --p-cell-border: #D9CDB5;
    --p-cell-blocked: #16130F;
    --p-cell-word: #C9D4F7;
    --p-cell-text: #1F2A44;
    --p-cell-accent: #2448C9;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--p-bg);
  color: var(--p-text);
  font-family: var(--p-font-ui);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--p-font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--p-text);
  text-wrap: balance;
}
p, li, dd { text-wrap: pretty; }

a { color: var(--p-primary); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

::selection { background: var(--p-blue-light); color: var(--p-text); }
:focus-visible { outline: 2px solid var(--p-primary); outline-offset: 3px; border-radius: 4px; }
input, textarea { caret-color: var(--p-primary); }
html { scrollbar-color: var(--p-gray-300) var(--p-bg); }
img { max-width: 100%; height: auto; }

.tabular, time { font-variant-numeric: tabular-nums; }

.p-container { width: 100%; max-width: var(--p-max); margin: 0 auto; padding: 0 20px; }

/* Soft card — the app's softCard */
.p-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-r-lg);
  box-shadow: var(--p-shadow);
  corner-shape: squircle;
}

/* Buttons — same as the app's primary/secondary buttons */
.p-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 22px;
  border-radius: var(--p-r-lg); corner-shape: squircle;
  font-family: var(--p-font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.2;
  text-decoration: none; border: 0; cursor: pointer;
  transition: transform 220ms var(--p-ease), box-shadow 220ms var(--p-ease), background-color 220ms var(--p-ease);
}
.p-btn--primary { background: linear-gradient(135deg, var(--p-primary), var(--p-primary-end)); color: var(--p-on-primary); box-shadow: var(--p-shadow); }
.p-btn--secondary { background: var(--p-surface); color: var(--p-text); border: 1px solid var(--p-hairline); }
.p-btn:hover { transform: translateY(-1px); box-shadow: var(--p-shadow-lift); text-decoration: none; }
.p-btn:active { transform: translateY(0); }

/* Crossword tile row — the one ornament: a word set in grid cells */
.p-tiles { display: inline-flex; gap: 4px; }
.p-tile {
  width: 1.9em; height: 1.9em; display: inline-grid; place-items: center;
  background: var(--p-cell-bg); color: var(--p-cell-text);
  border: 1px solid var(--p-cell-border); border-radius: 6px;
  font-family: var(--p-font-display); font-weight: 700; text-transform: uppercase; line-height: 1;
  box-shadow: 0 1px 0 var(--p-cell-border);
}
.p-tile--word { background: var(--p-cell-word); }
.p-tile--blocked { background: var(--p-cell-blocked); border-color: var(--p-cell-blocked); box-shadow: none; }

/* Store badges */
.p-badges { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.p-badges a { display: inline-flex; min-height: 48px; align-items: center; border-radius: 10px; }
.p-badges img { height: 48px; width: auto; display: block; }

/* Footer shared by all pages */
.p-footer {
  border-top: 1px solid var(--p-hairline);
  background: var(--p-surface-sunk);
  color: var(--p-text-muted);
  padding: var(--p-xxl) 0 calc(var(--p-xxl) + env(safe-area-inset-bottom));
  font-size: 0.92rem;
}
.p-footer a { color: var(--p-text-muted); }
.p-footer a:hover { color: var(--p-primary); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Google's PNG badge carries its own transparent padding; trim it so both badges line up */
.p-badges .google-play-badge img, .google-play-badge img { height: 70px; margin: -11px -10px; }

/* Cross-page view transitions (same-origin navigations) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 220ms; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
.werpa-site-header { view-transition-name: site-header; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
