/* ================================================================
   852.games — shared styles (gallery + shared chrome)
   Warm Hong Kong paper-and-ink palette, light + dark.
   Individual games are self-contained; this drives the gallery
   and any page that opts in via <link rel="stylesheet" href="/style.css">.
   ================================================================ */

:root{
  --bg: #f1e7d6;
  --bg-2: #e9dcc3;
  --panel: #fbf4e6;
  --ink: #241f18;
  --ink-soft: #6a5c47;
  --line: #d8c6a4;
  --cinnabar: #b5231f;
  --cinnabar-2: #8c1714;
  --gold: #c4912f;
  --shadow: rgba(70,46,18,.22);
  --card-shadow: 0 10px 28px rgba(70,46,18,.16);
  --radius: 18px;
  --font-cjk: "LXGW WenKai TC","Kaiti SC","STKaiti","KaiTi","DFKai-SB","BiauKai","標楷體","楷體",serif;
  --font-ui: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg: #17130d;
    --bg-2: #211a11;
    --panel: #241d13;
    --ink: #f1e6cf;
    --ink-soft: #b59f7c;
    --line: #41331f;
    --cinnabar: #e0563f;
    --cinnabar-2: #c33b27;
    --gold: #e2b659;
    --shadow: rgba(0,0,0,.5);
    --card-shadow: 0 12px 34px rgba(0,0,0,.45);
  }
}

*{ box-sizing:border-box; }
html,body{ margin:0; }
body{
  font-family:var(--font-ui);
  color:var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(196,145,47,.16), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}

.wrap{ max-width:1080px; margin:0 auto; padding:48px 24px 64px; }

/* ---------- Header ---------- */
/* full-width sticky frosted bar (same effect as 852.news): sticks to the top,
   blurs + tints the cards scrolling under it. Children re-centre at max-width. */
.site-head{
  position:sticky; top:0; z-index:10;
  padding:14px 24px 12px;
  backdrop-filter:saturate(1.1) blur(6px);
  -webkit-backdrop-filter:saturate(1.1) blur(6px);   /* Safari needs the prefixed form */
  background:linear-gradient(180deg, color-mix(in srgb, var(--bg) 92%, transparent), transparent);
  border-bottom:1px solid var(--line);
}
.head-row{
  max-width:1080px; margin:0 auto;
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
}
.brand{
  flex:1 1 auto; min-width:0;
  font-family:var(--font-cjk);
  font-weight:700;
  font-size:clamp(40px,9vw,68px);
  line-height:.98;
  letter-spacing:.01em;
  margin:0;
  color:var(--ink);
  cursor:text;
  position:relative;
}
.brand .dot{ color:var(--cinnabar); }
/* the title doubles as a live game search — type to filter.
   the input is absolutely overlaid, and #brandText keeps reserving its box,
   so switching to search mode never changes the header height. */
#search{
  position:absolute; left:0; top:0; width:100%;
  display:none; font:inherit; color:var(--ink);
  background:transparent; border:0; outline:0; padding:0; margin:0;
  caret-color:var(--cinnabar);
}
#search::placeholder{ color:var(--ink-soft); opacity:.6; }
.brand.searching #brandText{ visibility:hidden; }
.brand.searching .caret{ display:none; }
.brand.searching #search{ display:block; }
/* arcade caret — hard blink, retro CRT feel */
.caret{
  display:inline-block; width:.42em; height:.86em;
  margin-left:.1em; vertical-align:-.04em;
  background:var(--cinnabar); border-radius:1px;
  animation:blink 1.1s steps(1,end) infinite;
}
.tagline{
  max-width:1080px; margin:18px auto 0;
  font-family:var(--font-cjk);
  color:var(--ink-soft);
  font-size:clamp(15px,3.6vw,19px);
  letter-spacing:.16em;
}
.marquee{ max-width:1080px; margin:14px auto 0; display:flex; align-items:center; gap:13px; }
.rule{
  height:3px; width:74px; border-radius:3px;
  background:linear-gradient(90deg,var(--cinnabar),var(--gold));
}
.start{
  font-family:var(--font-ui);
  font-size:11px; font-weight:700; letter-spacing:.22em;
  color:var(--cinnabar);
  background:none; border:0; padding:3px 10px; border-radius:999px; cursor:pointer;
  animation:blink 1.7s steps(1,end) infinite;
}
.start:hover,.start:focus-visible{ background:var(--cinnabar); color:var(--panel); animation:none; outline:none; }
@keyframes blink{ 50%{ opacity:0; } }
@media (prefers-reduced-motion: reduce){ .start{ animation:none; } }

/* self-hosted brush font for the seal characters (subset: 墨戲捌伍貳製) */
@font-face{
  font-family:'Bakudai Seal';
  font-weight:700;
  font-display:swap;
  src:url('./assets/fonts/Bakudai-Seal.woff2') format('woff2');
}

/* 朱紅印章 — hand-stamped, sits at the right of the header row */
.seal{
  flex:none;
  width:clamp(58px,13vw,84px); height:auto;
  transform:rotate(-5deg);
  filter:drop-shadow(0 3px 7px var(--shadow));
  opacity:.97;
}
.seal-ground{ fill:var(--cinnabar); }
.seal-frame{ fill:none; stroke:var(--panel); stroke-width:3.5; }
.seal-grid{ fill:none; stroke:var(--panel); stroke-width:2; }
.seal-char{
  font-family:'Bakudai Seal',var(--font-cjk); font-weight:700; font-size:41px;
  text-anchor:middle; dominant-baseline:middle;
  fill:var(--panel);
}
@media (prefers-reduced-motion: reduce){
  .caret,.start{ animation:none; }
}

/* ---------- Intro / 緣起 ---------- */
.intro{
  max-width:60ch; margin:-18px 0 38px;
  font-family:var(--font-cjk);
  color:var(--ink-soft);
  font-size:clamp(15px,2.4vw,17px);
  line-height:1.9;
}
.intro p{ margin:0; }

/* ---------- Card grid ---------- */
.grid{
  display:grid; gap:22px;
  grid-template-columns:repeat(auto-fill, minmax(248px,1fr));
}
.card{
  display:flex; flex-direction:column;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  overflow:hidden;
  text-decoration:none; color:inherit;
  box-shadow:var(--card-shadow);
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover{
  transform:translateY(-4px);
  border-color:var(--gold);
  box-shadow:0 16px 40px var(--shadow);
}
.card .thumb{
  display:block; width:100%; aspect-ratio:16/10; object-fit:cover;
  background:#cf9f60; border-bottom:1px solid var(--line);
}
.card .body{ position:relative; padding:16px 18px 18px; display:flex; flex-direction:column; gap:6px; }
.card .name{ font-family:var(--font-cjk); font-weight:700; font-size:24px; line-height:1.1; }
.card .en{ font-size:13px; letter-spacing:.16em; text-transform:uppercase; color:var(--ink-soft); }
.card .tags{ margin-top:8px; display:flex; gap:7px; flex-wrap:wrap; }
.tag{
  font-size:12px; letter-spacing:.08em;
  padding:3px 10px; border-radius:999px;
  background:rgba(181,35,31,.10); color:var(--cinnabar);
  border:1px solid rgba(181,35,31,.22);
}
@media (prefers-color-scheme: dark){
  .tag{ background:rgba(224,86,63,.14); border-color:rgba(224,86,63,.32); }
}

/* Coming-soon placeholder */
.card.soon{
  background:transparent; border-style:dashed; box-shadow:none; cursor:default;
}
.card.soon:hover{ transform:none; border-color:var(--line); box-shadow:none; }
.card.soon .thumb{
  background:
    repeating-linear-gradient(45deg, rgba(120,90,40,.06) 0 12px, transparent 12px 24px);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-cjk); font-size:40px; color:var(--ink-soft); opacity:.6;
}
.card.soon .name{ color:var(--ink-soft); }

/* ---------- Card long-press → description popup ---------- */
.intro-hint{ margin:12px 0 0; font-size:13px; color:var(--ink-soft); opacity:.78; letter-spacing:.04em; }
.card{ -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }  /* no iOS long-press callout */

/* "i" badge — top-right of the card text area, opens the same 詳情 popup */
.card-info{
  position:absolute; top:13px; right:13px; z-index:1;
  width:26px; height:26px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  border:1.5px solid var(--line); background:var(--panel);
  color:var(--ink-soft);
  font-family:Georgia,"Times New Roman",serif; font-style:italic; font-weight:700;
  font-size:16px; line-height:1; cursor:pointer;
  transition:color .16s ease, border-color .16s ease, background .16s ease;
}
.card-info:hover,.card-info:focus-visible{
  color:var(--cinnabar); border-color:var(--cinnabar);
  background:rgba(181,35,31,.08); outline:none;
}

.info-pop{
  position:fixed; inset:0; z-index:60; display:none;
  align-items:center; justify-content:center; padding:24px;
  background:color-mix(in srgb, var(--ink) 56%, transparent);
  -webkit-backdrop-filter:blur(7px); backdrop-filter:blur(7px);
}
.info-pop.show{ display:flex; }
.info-card{
  position:relative;
  width:100%; max-width:440px; max-height:84vh; overflow:auto;
  background:var(--panel); color:var(--ink);
  border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:0 24px 60px var(--shadow);
  padding:26px 24px 24px;
}
.info-title{ font-family:var(--font-cjk); font-weight:700; font-size:26px; line-height:1.1; }
.info-en{ font-size:12px; letter-spacing:.18em; text-transform:uppercase; color:var(--ink-soft); margin-top:4px; }
.info-body{ margin-top:14px; font-family:var(--font-cjk); font-size:16px; line-height:1.85; }
.info-body p{ margin:0 0 12px; }
.info-body p:last-child{ margin-bottom:0; }
.info-credit{ font-size:14px; color:var(--ink-soft); border-top:1px solid var(--line); padding-top:12px; }
.info-credit a{ color:var(--cinnabar); text-decoration:none; white-space:nowrap; }
.info-credit a:hover{ text-decoration:underline; }
.info-close{
  position:absolute; top:8px; right:10px;
  width:34px; height:34px; border:0; border-radius:50%;
  background:transparent; color:var(--ink-soft); font-size:24px; line-height:1; cursor:pointer;
}
.info-close:hover{ background:rgba(120,90,40,.12); color:var(--ink); }

/* ---------- Footer ---------- */
.site-foot{
  margin-top:44px; padding-top:18px; border-top:1px solid var(--line);
  color:var(--ink-soft); font-size:13.5px; letter-spacing:.04em;
  display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px;
}
.site-foot a{ color:var(--cinnabar); text-decoration:none; }
.site-foot a:hover{ text-decoration:underline; }

/* ---------- Shared chrome for game pages that opt in ---------- */
.back-link{
  position:fixed; top:14px; left:14px; z-index:50;
  font-family:var(--font-cjk); font-size:15px; letter-spacing:.1em;
  padding:7px 13px; border-radius:999px; text-decoration:none;
  color:var(--ink); background:rgba(251,244,230,.86);
  border:1px solid var(--line); box-shadow:0 3px 10px var(--shadow);
  -webkit-backdrop-filter:blur(4px); backdrop-filter:blur(4px);
}
.back-link:hover{ border-color:var(--gold); }
