/* Historias, 2026-11-17 redesign after Gemini's review ("looks AI-generated").
   Direction: candlelit case file / paperback jacket. Warm paper, ink, one oxblood accent, sharp
   corners (2-4px), hairline rules instead of shadows, Cormorant Garamond for display and
   Plus Jakarta Sans for the interface. No emoji anywhere in the chrome.
   Every page loads this file after shared/base.css; pages carry no <style> of their own. */
:root{
  --bg:#f2f2f0;--card:#fbfbfa;--ink:#1a1a1c;--sub:#55555a;--line:#d8d8d6;--rule:#1a1a1c;
  --accent:#8c2f23;--accent-ink:#ffffff;--soft:#e7e7e4;--good:#2f6b45;--warn:#8a4a12;
  --brand:#1a1a1c;--clue-bg:#ecebe8;--nuevo:#8c2f23;--panel:rgba(242,242,240,.94);
  --f:"Plus Jakarta Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
  --d:"Cormorant Garamond","Iowan Old Style",Georgia,serif;color-scheme:light
}
:root[data-theme="dark"]{
  --bg:#131315;--card:#1b1b1e;--ink:#ececee;--sub:#a5a5ab;--line:#333338;--rule:#ececee;
  --accent:#e0806c;--accent-ink:#131315;--soft:#242428;--good:#7cc596;--warn:#e4a35e;
  --brand:#ececee;--clue-bg:#232327;--nuevo:#e0806c;--panel:rgba(19,19,21,.92);color-scheme:dark
}
body{background:var(--bg);color:var(--ink);font:16px/1.6 var(--f)}
a{color:var(--accent)}

/* ---- header: wordmark, stamp, plain icon tools */
header.top{border-bottom:1px solid var(--rule);padding:8px 0 10px;margin-bottom:18px;align-items:center}
.brand{font:600 italic 30px/1 var(--d);letter-spacing:0;color:var(--brand)}
header.top .pill{border:1px solid currentColor;background:none;color:var(--accent);border-radius:2px;font:700 11px/1 var(--f);letter-spacing:.12em;text-transform:uppercase;padding:5px 7px}
.tools{gap:0}
.iconbtn{border:0;background:none;border-radius:4px;color:var(--ink)}
.iconbtn:hover{background:var(--soft)}
.iconbtn svg{width:21px;height:21px;display:block}
.iconbtn[aria-pressed="false"]{opacity:.45}

/* phones: one header row (wordmark + tools); the header tag is extra there */
@media (max-width:520px){header.top{flex-wrap:nowrap}header.top .pill{display:none}.tools{margin-left:auto}}

/* ---- type */
h1{font:600 38px/1.08 var(--d);letter-spacing:-.01em;margin:4px 0 12px;color:var(--ink)}
h2{font:600 26px/1.2 var(--d);margin:28px 0 10px;color:var(--ink)}
h3{font-family:var(--d)}
.muted{color:var(--sub)}
.lede{font-size:17px;max-width:34em}

/* ---- surfaces: paper, hairlines, no shadows */
.card{background:var(--card);border:1px solid var(--line);border-radius:3px;padding:18px;box-shadow:none}
.btn{border-radius:3px;min-height:48px;font:700 15px var(--f);letter-spacing:.02em;box-shadow:none;background:var(--accent);color:var(--accent-ink)}
.btn.ghost{background:transparent;color:var(--ink);border:1px solid var(--ink)}
.btn.ghost:hover{background:var(--soft)}
input,textarea,select{background:var(--card);border:1px solid var(--line);border-radius:3px;color:var(--ink);min-height:48px}
input:focus,textarea:focus{border-color:var(--ink)}
textarea{min-height:110px}
.pill{border-radius:2px;background:none;border:1px solid var(--line);color:var(--sub);font:700 11px/1.4 var(--f);letter-spacing:.1em;text-transform:uppercase;padding:3px 7px}
.foot{border-top:1px solid var(--line);padding-top:14px}
.legal p,.legal li{color:var(--ink)}
.legal ul{padding-left:20px}
.paywall{border-radius:3px;border:1px solid var(--ink)}
.gate .box{border-radius:3px}

/* ---- list page */
.count{font:400 15px var(--f);color:var(--sub);margin-left:8px}
.chips{display:flex;gap:0;overflow-x:auto;margin:0 0 6px;border-bottom:1px solid var(--line);scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{flex:none;min-height:46px;padding:10px 14px;border:0;border-bottom:2px solid transparent;margin-bottom:-1px;background:none;color:var(--sub);font:600 15px var(--f);cursor:pointer;border-radius:0}
.chip:first-child{padding-left:0}
.chip:hover{color:var(--ink)}
.chip[aria-pressed="true"]{color:var(--ink);border-bottom-color:var(--accent)}
#stories{display:grid;gap:0}
.card.story{content-visibility:auto;contain-intrinsic-size:auto 170px;display:grid;grid-template-columns:96px minmax(0,1fr);gap:16px;align-items:start;background:none;border:0;border-bottom:1px solid var(--line);border-radius:0;padding:18px 0;color:inherit;text-decoration:none}
.card.story:hover h3{text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px}
/* the jacket: a small paperback cover drawn in CSS, one pattern per genre */
.jacket{contain:paint;position:relative;width:96px;aspect-ratio:3/4;border-radius:2px;overflow:hidden;color:#fbf7ef;display:flex;flex-direction:column;justify-content:space-between;padding:10px 10px 9px;border:1px solid var(--ink);box-shadow:inset 0 0 0 4px rgba(0,0,0,.0),inset 0 0 0 5px rgba(251,247,239,.45)}
/* paper grain over the pattern so the jacket reads as printed stock, not CSS */
.jacket::after{content:"";position:absolute;inset:0;pointer-events:none;opacity:.10;mix-blend-mode:multiply;background-image:url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27160%27 height=%27160%27%3E%3Cfilter id=%27n%27%3E%3CfeTurbulence type=%27fractalNoise%27 baseFrequency=%27.9%27 numOctaves=%273%27 stitchTiles=%27stitch%27/%3E%3C/filter%3E%3Crect width=%27100%25%27 height=%27100%25%27 filter=%27url(%23n)%27/%3E%3C/svg%3E")}
.jacket::before{content:"";position:absolute;inset:5px;pointer-events:none;opacity:.55}
.jacket.g-misterio::before{background:repeating-linear-gradient(135deg,rgba(255,255,255,.10) 0 1px,transparent 1px 7px)}
.jacket.g-romantasy::before{background:radial-gradient(circle at 70% 32%,rgba(255,255,255,.26) 0 15px,transparent 16px),radial-gradient(rgba(255,255,255,.16) 1px,transparent 1.5px) 0 0/9px 9px}
.jacket.g-cozy::before{background:linear-gradient(90deg,rgba(255,255,255,.10) 50%,transparent 50%) 0 0/12px 12px,linear-gradient(rgba(255,255,255,.10) 50%,transparent 50%) 0 0/12px 12px}
/* with a picture: the painting fills the jacket, a dark fade at top and bottom keeps the words legible */
.jacket.pic{background:#1a1a1c!important}
.jacket.pic img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
.jacket.pic::before{inset:0;opacity:1;background:linear-gradient(rgba(10,10,12,.62),rgba(10,10,12,0) 34%,rgba(10,10,12,0) 58%,rgba(10,10,12,.72))}
.jacket.pic::after{opacity:.06;z-index:1}
.jacket.pic img{z-index:0}
.jacket.pic::before{z-index:1}
.jacket.pic>span{z-index:2}
.jacket .kicker{position:relative;font:700 8px/1.25 var(--f);letter-spacing:.16em;text-transform:uppercase;opacity:.92}
.jacket .rule{position:relative;height:1px;background:currentColor;opacity:.55;margin-top:auto;margin-bottom:6px}
.jacket .num{position:relative;font:600 italic 32px/1 var(--d);align-self:flex-end}
.card.story .meta{font:700 11px/1.4 var(--f);letter-spacing:.1em;text-transform:uppercase;color:var(--sub);margin:2px 0 6px}
.card.story .meta .free,.card.story .meta .new{color:var(--accent)}
.card.story h3{font:600 23px/1.15 var(--d);margin:0 0 6px;color:var(--ink)}
.card.story p{margin:0;color:var(--sub);font-size:15px;line-height:1.55}
.write{border-top:1px solid var(--rule);margin-top:28px;padding-top:18px}

/* ---- play page */
#intro{font:500 italic 21px/1.5 var(--d);color:var(--ink);border-left:0;background:none;padding:0 0 18px;margin:6px 0 8px;border-bottom:1px solid var(--line)}
#intro::first-letter{float:left;font:600 58px/.82 var(--d);font-style:normal;padding:6px 8px 0 0;color:var(--accent)}
.people{display:flex;gap:0;overflow-x:auto;border-bottom:1px solid var(--line);scrollbar-width:none;margin-bottom:4px}
.people::-webkit-scrollbar{display:none}
.who{flex:none;display:grid;grid-template-columns:36px auto;grid-template-rows:auto auto;column-gap:10px;align-items:center;min-height:56px;padding:8px 14px 8px 2px;margin-right:10px;background:none;border:0;border-bottom:2px solid transparent;margin-bottom:-1px;color:var(--sub);font:inherit;text-align:left;cursor:pointer;border-radius:0}
.who[aria-pressed="true"]{color:var(--ink);border-bottom-color:var(--accent)}
.who .av{grid-row:1 / span 2;width:36px;height:36px;border-radius:2px;border:1px solid currentColor;display:flex;align-items:center;justify-content:center;font:600 italic 17px/1 var(--d);flex:none;background:none;color:inherit}
.who[aria-pressed="true"] .av{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.who small{display:block;grid-column:2;font-size:12px;color:var(--sub);line-height:1.25;max-width:12em}
.chat{display:flex;flex-direction:column;gap:16px;padding:18px 0;margin:0 0 6px;max-height:420px;overflow-y:auto;background:none;border:0}
.msg{font-size:16px;line-height:1.62;max-width:60ch;padding:0;background:none;border-radius:0}
.msg::before{content:attr(data-who);display:block;font:700 11px/1.4 var(--f);letter-spacing:.12em;text-transform:uppercase;color:var(--sub);margin-bottom:2px}
.msg.them{color:var(--ink)}
.msg.me{padding-left:14px;border-left:2px solid var(--accent);color:var(--ink)}
.msg.me::before{color:var(--accent)}
.msg.clue{border:1px dashed var(--accent);border-radius:2px;background:var(--clue-bg);color:var(--ink);padding:10px 12px;font-size:14px}
.msg.clue::before{color:var(--accent)}
#askform{display:flex;gap:8px;position:sticky;bottom:0;background:var(--bg);padding:10px 0 calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--line)}
#askform input{flex:1;min-width:0}
#askform .btn{padding:0 18px}
.clues ul{list-style:none;padding:0;margin:0;counter-reset:pista}
.clues li{counter-increment:pista;border-bottom:1px solid var(--line);padding:10px 0 10px 34px;position:relative;font-size:15px}
.clues li::before{content:counter(pista,upper-roman);position:absolute;left:0;top:9px;font:600 italic 17px/1.2 var(--d);color:var(--accent)}
.clues li.muted{padding-left:0}
.clues li.muted::before{content:none}
#cluecount{vertical-align:middle;margin-left:6px}
.verdict{display:flex;flex-direction:column;gap:8px;margin-top:12px}
.verdict .btn.ghost{justify-content:flex-start;text-align:left}
#result:not(:empty){margin-top:16px;padding:18px;border:1px solid var(--ink);border-radius:3px;text-align:center}
.result{font:600 24px/1.25 var(--d);margin-bottom:12px}
.btn.share{width:100%}

/* phone order: talk first, then the clue list, then the verdict */
#game:not([hidden]){display:flex;flex-direction:column}
#game .side,#game .main{display:contents}
#game .cluebox{order:1}
#game #question,#game #question~*{order:2}

/* ---- the story's picture behind the page (play page only). The painting stays fixed; the top of the
   page (title) sits on it like a book cover, then the paper panel slides over it. It changes with the
   case: start, tension, solved (jugar.js setStage). */
.stage{position:fixed;inset:0;z-index:-1;background:#101012;pointer-events:none}
.stage .layer{position:absolute;inset:0;background:center/cover no-repeat;opacity:0;transition:opacity 1.4s ease}
.stage .layer.on{opacity:1}
.stage::after{content:"";position:absolute;inset:0;background:linear-gradient(rgba(8,8,10,.55),rgba(8,8,10,.15) 30%,rgba(8,8,10,.35) 60%,rgba(8,8,10,.75))}
@media (prefers-reduced-motion:reduce){.stage .layer{transition:none}}
/* phones: the painting fills only the top of the screen, so the whole scene shows above the title
   instead of a dark sliver of a tall crop */
@media (max-width:959px){.stage .layer{bottom:auto;height:48vh}.stage::after{background:linear-gradient(rgba(8,8,10,.45),rgba(8,8,10,.1) 25%,rgba(8,8,10,.5) 40vh,#101012 48vh)}}
.stage{display:none}
body.has-stage .stage{display:block}
body.has-stage{background:#101012}
.wrap.play .cover .kicker{display:none;margin:0 0 6px;font:700 12px/1.3 var(--f);letter-spacing:.16em;text-transform:uppercase}
body.has-stage .wrap.play{padding-top:0;padding-bottom:0;background:none}
body.has-stage .wrap.play header.top{border-bottom-color:rgba(255,255,255,.35);color:#fff;padding-top:14px}
body.has-stage .wrap.play header.top .brand,body.has-stage .wrap.play header.top .iconbtn{color:#fff}
body.has-stage .wrap.play header.top .iconbtn:hover{background:rgba(255,255,255,.14)}
body.has-stage .wrap.play header.top .pill{display:none}
body.has-stage .wrap.play .cover{min-height:30vh;display:flex;flex-direction:column;justify-content:flex-end;padding:0 0 22px;color:#fff;text-shadow:0 1px 18px rgba(0,0,0,.55)}
body.has-stage .wrap.play .cover .kicker{display:block;color:#fff;opacity:.9}
body.has-stage .wrap.play .cover h1{color:#fff;margin-bottom:0}
/* the paper: one panel under the title holding everything else */
body.has-stage .wrap.play>#game,body.has-stage .wrap.play>#locked:not(:empty),body.has-stage .wrap.play>.foot,body.has-stage .wrap.play>.links{background:var(--bg);margin:0 -16px;padding-left:16px;padding-right:16px}
body.has-stage .wrap.play>#game{padding-top:20px;border-top:1px solid var(--rule)}
body.has-stage .wrap.play>#locked:not(:empty){padding-top:20px;padding-bottom:4px;border-top:1px solid var(--rule)}
body.has-stage .wrap.play>.foot{margin-top:0;padding-top:24px;border-top:0}
body.has-stage .wrap.play>.links{margin-top:0;padding-bottom:96px}
body.has-stage #askform{background:var(--bg)}
/* who you are talking to: the portrait above the transcript */
.speaker{display:flex;align-items:center;gap:14px;padding:0 0 14px;border-bottom:1px solid var(--line)}
.speaker[hidden]{display:none}
.speaker img{width:72px;height:72px;object-fit:cover;border-radius:2px;border:1px solid var(--line);flex:none;background:var(--soft)}
.speaker b{display:block;font:600 22px/1.15 var(--d)}
.speaker small{display:block;color:var(--sub);font-size:13px;line-height:1.35;margin-top:2px}
.who .av.pic{overflow:hidden;padding:0;border-color:var(--line)}
.who .av.pic img{width:100%;height:100%;object-fit:cover;display:block}
.who[aria-pressed="true"] .av.pic{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.msg.them.hasface::before{padding-left:30px;min-height:24px;line-height:24px;background:var(--face) left center/24px 24px no-repeat}

/* ---- writers page */
ul{color:var(--sub)}
#go.btn{width:100%;margin-top:20px}
#msg{margin-top:12px;font-weight:700;text-align:center}

/* ---- wide screens: use the width */
@media (min-width:960px){
  .wrap{max-width:1080px;padding-left:32px;padding-right:32px}
  .brand{font-size:34px}
  h1{font-size:54px;max-width:16em}
  .lede{font-size:18px}
  #stories{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:48px}
  .card.story{grid-template-columns:120px minmax(0,1fr);gap:20px}
  .jacket{width:120px}
  .jacket .num{font-size:40px}
  #game .side,#game .main{display:block}
  #game .cluebox,#game #question,#game #question~*{order:0}
  #game:not([hidden]){display:grid;grid-template-columns:minmax(0,5fr) minmax(0,7fr);column-gap:56px;align-items:start}
  #game .side{position:sticky;top:16px;max-height:calc(100vh - 32px);overflow-y:auto;overscroll-behavior:contain;padding-right:12px;padding-bottom:28px;scrollbar-width:thin;-webkit-mask-image:linear-gradient(#000 calc(100% - 28px),transparent);mask-image:linear-gradient(#000 calc(100% - 28px),transparent)}
  #game .side .people{flex-direction:column;border-bottom:0;overflow:visible}
  #game .side .who{margin:0;border-bottom:1px solid var(--line);border-left:2px solid transparent;padding-left:10px;width:100%}
  #game .side .who[aria-pressed="true"]{border-left-color:var(--accent);border-bottom-color:var(--line)}
  #game .main h2:first-child{margin-top:0}
  .chat{max-height:56vh}
  .legal{max-width:760px}
  body.has-stage .wrap.play>#game,body.has-stage .wrap.play>#locked:not(:empty),body.has-stage .wrap.play>.foot,body.has-stage .wrap.play>.links{margin:0 -32px;padding-left:32px;padding-right:32px}
  body.has-stage .wrap.play .cover{min-height:40vh}
  .speaker img{width:88px;height:88px}
  /* the side pane sticks under the top of the window; the panel's paper is behind it */
  body.has-stage #game .side{top:16px}
}
