/* guildle's styles, part 1 of 10 (base.css). The basics: colours and fonts (both themes), the top bar, the recruit screen and its reveal.
   The parts load in order (index.html) and later rules build on earlier ones. */

/* guildle styles
 * Sections: tokens and page · top bar and dev tray · home (scene, stage, party) · cards
 * · reveal effects · roster · overlays · sign-in and account (at the end). */

:root {
  /* Theme (Night by default; [data-theme="light"] is Day, below). Night: a navy sky with parchment
     text. Day: a parchment page with navy ink. Set on <html> by theme.js (Light, Dark or by the time). */
  color-scheme: dark;
  --felt: #151c30;
  --felt-deep: #0e1424;
  --felt-line: #2b3756;
  --panel-rgb: 11, 17, 33;          /* translucent panels and inputs over the page */
  --shade-rgb: 6, 10, 22;           /* overlays that dim the page (always dark) */
  --vignette: rgba(4, 7, 18, .62);
  --grid: rgba(232, 214, 168, .06);
  --grid-major: rgba(232, 214, 168, .12);
  --brass: #c9994a;
  --brass-dim: #8f6c34;
  --gold: #f0cf8e;                  /* accent text on the page */
  --gold-hi: #f0cf8e;               /* gold on dark chips (the same in both themes) */
  --rune: #5fcfae;
  --text: #efe3c6;
  --text-dim: #a4abc2;
  --good: #9fe0b2; --bad: #ff8a7a;
  --card: #f4ecda;
  --card-edge: #e3d6b8;
  --ink: #2b2118;
  --ink-soft: #6b5a45;
  --back: #6e2a2a;
  --back-deep: #4d1b1d;
  --r-common: #8b8f86;
  --r-uncommon: #3f8f55;
  --r-rare: #3b6fbf;
  --r-epic: #8a48c2;
  --r-legendary: #d29a12;
  /* rarity as TEXT on the page (names in the feed, lists): the rarity colours tuned to read on each theme */
  --rt-common: #b8bcb2; --rt-uncommon: #6cc283; --rt-rare: #8bb2f2; --rt-epic: #c094ea; --rt-legendary: #f0c040;
  /* buttons: one look everywhere.
     Action (.btn-like): a dark chip with gold letters, the same in both themes. Secondary: an outline on the panel.
     Big (the main call on a screen: Send your party, Continue, Rise): the dark chip again, in the italic serif.
     Controls (icon buttons, closes, the map's zoom): a square on the panel. Labels and tags stay at 5px corners. */
  --btn-r: 8px; --btn-h: 34px; --btn-font: 700 .88rem/1 var(--sans);
  --btn-bg: #1b120a; --btn-bg-hi: #2a1d10; --btn-line: #6b4f2a; --btn-fg: #f0cf8e;
  --btn2-bg: rgba(var(--panel-rgb), .8); --btn2-line: var(--brass-dim); --btn2-fg: var(--text);
  --big-r: 10px; --big-h: 48px; --big-font: italic 400 1.2rem/1.1 var(--serif);
  --ctl-r: 10px; --ctl-bg: rgba(var(--panel-rgb), .85);
  --wear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='700' height='700'%3E%3Cfilter id='w' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006' numOctaves='3' seed='7' stitchTiles='stitch' result='a'/%3E%3CfeColorMatrix in='a' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  3.4 0 0 0 -1.05' result='p'/%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='1' seed='3' stitchTiles='stitch' result='b'/%3E%3CfeColorMatrix in='b' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  3 0 0 0 -.75' result='s'/%3E%3CfeComposite in='p' in2='s' operator='in'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
  --page-w: 1080px; /* shared by the top bar, dev tray and roster so their edges line up */
  --display: "IM Fell English SC", "Iowan Old Style", Georgia, serif;
  --serif: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --sans: "Alegreya Sans", "Gill Sans", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { min-height: 100vh; min-height: 100svh; } /* the felt always reaches the bottom of the screen (html's felt fills any extra) */
html { background: var(--felt); scrollbar-gutter: stable; } /* no sideways jump when a scrollbar appears */
body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  padding-inline: 16px;
  position: relative;
  isolation: isolate;
  background-color: var(--felt);
}
/* Background layers sit on their own fixed, GPU-composited planes, so animations
   that change the page's layout never make the browser repaint them. */
/* Both layers are sized to the LARGEST viewport (100lvh), not the visible one. On phones the visible
   height changes as the address bar slides in and out while scrolling; layers that followed it
   would resize, and the diagonal lattice and vignette would jump. */
body::after {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100lvh; z-index: -2; pointer-events: none;
  background-image:
    radial-gradient(ellipse at 50% 35%, transparent 40%, var(--vignette) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .93  0 0 0 0 .9  0 0 0 0 .8  0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 100% 100%, 240px 240px;
  transform: translateZ(0);
}
/* diamond lattice, rubbed away in patches */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100lvh; z-index: -1; pointer-events: none;
  transform: translateZ(0); will-change: transform;
  background-image:
    repeating-linear-gradient(45deg, var(--grid-major) 0 1px, transparent 1px 104px),
    repeating-linear-gradient(-45deg, var(--grid-major) 0 1px, transparent 1px 104px),
    repeating-linear-gradient(45deg, var(--grid) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(-45deg, var(--grid) 0 1px, transparent 1px 26px);
  -webkit-mask-image: var(--wear); mask-image: var(--wear);
  -webkit-mask-size: 700px 700px; mask-size: 700px 700px;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- Top bar ---------- */
.ibtn {
  position: relative; width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--ctl-bg); border: 1px solid var(--felt-line); border-radius: var(--ctl-r); cursor: pointer; color: var(--text);
}
.ibtn:hover { border-color: var(--brass-dim); color: var(--gold); }
.ibtn[aria-pressed="true"] { border-color: var(--brass); background: rgba(201, 153, 74, .14); }
.ibtn svg { width: 18px; height: 18px; }

/* Dev tray */
/* .dev-btn is the game's secondary button (an outline on the panel), wherever it's used */
.dev-btn { min-height: var(--btn-h); font: var(--btn-font); color: var(--btn2-fg); background: var(--btn2-bg); border: 1px solid var(--btn2-line); border-radius: var(--btn-r); padding: 8px 14px; cursor: pointer; }
.dev-btn:hover { border-color: var(--brass); color: var(--gold); }
.dev-btn:disabled { opacity: .5; cursor: default; }
.dev-btn.armed { background: #7a2a26; border: 1px solid #c4564d; }

/* ---------- Recruit view ---------- */
.draw {
  /* The card sits the same distance below the top bar as the banner sits below the card. */
  --lead: 48px;                 /* top bar -> flavour text */
  --flav-h: 3.45rem;            /* two lines of flavour text */
  --gap: 14px;                  /* flavour text -> card */
  max-width: var(--page-w); margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: var(--gap);
  padding-block: var(--lead) 40px; text-align: center;
}
@media (max-width: 520px) { .draw { --flav-h: 5.2rem; --lead: 32px; } } /* room for three lines on phones */
.flavour { margin: 0; max-width: 34em; min-height: var(--flav-h); justify-content: center; font: italic 1.15rem/1.5 var(--serif); color: var(--text-dim); text-wrap: balance; display: flex; align-items: center; }
.reply-wrap { display: none; }
/* Intro: the scene fills the screen until the player answers it */
.draw.intro { padding-top: clamp(72px, 24vh, 240px); }
.draw.intro .flavour { font-size: clamp(1.6rem, 3.6vw, 2.5rem); line-height: 1.35; max-width: 20em; min-height: 0; color: var(--text); }
.draw.intro .reply-wrap { display: block; margin-top: 18px; animation: fadeup .7s .5s both; }
.draw.intro .stage, .draw.intro .recruit-wrap, .draw.intro .result, .draw.intro .save-note, .draw.intro .party { display: none; }
.draw { transition: padding-top .6s cubic-bezier(.3,.7,.2,1); }
.flavour { transition: font-size .6s cubic-bezier(.3,.7,.2,1), color .6s, max-width .6s; }
.draw.arrive .stage { animation: fadeup .7s .25s both; }
.draw.arrive .recruit-wrap { animation: fadeup .7s .45s both; }
@keyframes fadeup { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.reply {
  font: italic 1.25rem/1.2 var(--serif); color: var(--gold); cursor: pointer;
  background: rgba(var(--panel-rgb), .55); border: 1px solid var(--brass-dim); border-radius: 10px;
  padding: 12px 22px 12px 18px; display: inline-flex; align-items: center; gap: 10px;
  box-shadow: 0 0 18px rgba(240, 207, 142, .12); transition: border-color .2s, box-shadow .2s, transform .1s;
}
.reply::before { content: "\276F"; font: 400 .9rem/1 var(--sans); color: var(--brass); font-style: normal; }
.reply:hover { border-color: var(--gold); box-shadow: 0 0 22px rgba(240, 207, 142, .28); }
.reply:active { transform: translateY(1px); }
.flavour.fresh { animation: fadein .8s ease both; }
@keyframes fadein { from { opacity: .2; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Card width also shrinks on short screens so the banner and result line stay in view. */
.stage { position: relative; width: min(380px, 88vw, max(240px, calc((100vh - 470px) * .714))); width: min(380px, 88vw, max(240px, calc((100svh - 470px) * .714))); /* svh: stays put when the phone's address bar moves */ perspective: 1400px; }

/* ---------- Recruitment reveal ---------- */
.stage { --glow: var(--r-common); --amp: 0; }
.stage.glowing .flipper { animation: rattle calc(.34s - var(--amp) * .045s) linear infinite; }
@keyframes rattle {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(calc(var(--amp) * -1.1px), calc(var(--amp) * .6px)) rotate(calc(var(--amp) * -.35deg)); }
  40% { transform: translate(calc(var(--amp) * .9px), calc(var(--amp) * -.8px)) rotate(calc(var(--amp) * .3deg)); }
  60% { transform: translate(calc(var(--amp) * -.7px), calc(var(--amp) * -.5px)) rotate(calc(var(--amp) * .2deg)); }
  80% { transform: translate(calc(var(--amp) * 1px), calc(var(--amp) * .7px)) rotate(calc(var(--amp) * -.25deg)); }
}
.stage.glowing .cardback {
  border-color: var(--glow);
  box-shadow: 0 0 calc(14px + var(--amp) * 7px) calc(2px + var(--amp) * 2px) var(--glow), 0 0 calc(40px + var(--amp) * 14px) color-mix(in srgb, var(--glow) 45%, transparent), 0 16px 34px rgba(0,0,0,.5);
  transition: box-shadow .7s ease-in-out, border-color .7s ease-in-out;
}
.stage.glowing .cardback .qc { color: var(--glow); transition: color .7s ease-in-out; }

.dice-layer { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 3; pointer-events: none; }
.die { position: absolute; left: 0; top: 0; width: 30px; height: 30px; margin: -15px 0 0 -15px; display: grid; place-items: center;
  font: 800 1rem/1 var(--sans); color: #2b1d0e; background: linear-gradient(145deg, #fbf3df, #dcc79c); border: 1px solid #9c6d31; border-radius: 7px;
  box-shadow: 0 3px 8px rgba(0,0,0,.4), 0 0 10px color-mix(in srgb, var(--glow) 60%, transparent); }
.die.drop { opacity: .45; text-decoration: line-through 2px; filter: grayscale(.6); }
.stat-pop { position: absolute; left: 0; top: 0; white-space: nowrap; transform: translate(-50%, -50%); font: 400 1.35rem/1 var(--display); color: var(--text); text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.stat-pop b { font: 800 1.5rem/1 var(--sans); color: var(--gold); margin-left: 6px; }
.stat-pop.hi b { color: #fff3c4; text-shadow: 0 0 12px var(--gold); }
.stat-pop.lo b { color: var(--text-dim); }


.rays { position: absolute; left: 50%; top: 50%; width: 260%; aspect-ratio: 1; margin: -130% 0 0 -130%; transform: scale(.6); /* centred with margins so the spin can't orbit */ z-index: 0; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 222, 140, .38) 0deg 5deg, transparent 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 62%); mask-image: radial-gradient(circle, #000 18%, transparent 62%);
  transition: opacity 1s, transform 1.2s cubic-bezier(.2,.8,.2,1); }
.rays.on { opacity: 1; transform: scale(1); animation: spin 14s linear infinite; }
@keyframes spin { from { rotate: 0deg; } to { rotate: 360deg; } }
.flipper { position: relative; z-index: 1; }

.stage.pop { animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.09); } 100% { transform: scale(1); } }

.spotlight { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .8s, visibility 0s linear .8s;
  background: radial-gradient(ellipse 45% 55% at 50% 45%, rgba(var(--shade-rgb), .15), rgba(var(--shade-rgb), .82)); }
.spotlight.on { opacity: 1; visibility: visible; transition: opacity .8s; }
body.spotlit .stage { z-index: 6; }
.flash { position: fixed; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 45%, #fffbe8, rgba(255, 240, 200, .6) 40%, transparent 75%); }
.flash:not(.go) { visibility: hidden; } /* (these full-screen sheets took a layer and a blend each, all the time, with nothing to show) */
.flash.go { animation: flash .75s ease-out; }
@keyframes flash { 0% { opacity: 0; } 12% { opacity: .95; } 100% { opacity: 0; } }
.fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 7; pointer-events: none; }
.fx:not(.on) { visibility: hidden; }
.ring { position: fixed; z-index: 7; pointer-events: none; border-radius: 50%; border: 3px solid var(--c); box-shadow: 0 0 18px var(--c), inset 0 0 18px var(--c); transform: translate(-50%, -50%); animation: ring .9s ease-out forwards; }
@keyframes ring { from { width: 40px; height: 40px; opacity: 1; } to { width: 720px; height: 720px; opacity: 0; } }
.flipper { position: relative; aspect-ratio: 5 / 7; transition: transform .9s cubic-bezier(.3,.7,.2,1); transform-style: preserve-3d; }
.flipper.shown { transform: rotateY(180deg); }
.flipper > .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flipper > .face.front { transform: rotateY(180deg); }
.flipper.shake { animation: shake .5s ease; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }

.cardback {
  container-type: inline-size;
  border-radius: 14px; border: 6px solid var(--card);
  background:
    repeating-linear-gradient(45deg, transparent 0 9px, rgba(255,255,255,.06) 9px 10px),
    repeating-linear-gradient(-45deg, transparent 0 9px, rgba(255,255,255,.06) 9px 10px),
    radial-gradient(circle at 50% 50%, var(--back) 0%, var(--back-deep) 100%);
  box-shadow: 0 16px 34px rgba(0,0,0,.5);
  display: grid; place-items: center; position: relative;
}
.cardback .qc { position: absolute; font: 400 11cqw/1 var(--display); color: var(--brass); opacity: .85; }
.cardback .qc.tl { top: 5%; left: 7%; }
.cardback .qc.br { bottom: 5%; right: 7%; transform: rotate(180deg); }

/* Face down on the table, the card itself is the recruit button. Its back shows a
   "Recruit Adventurer" button, which fades away as the reveal starts. */
.cardback .card-cta {
  position: relative; z-index: 1; max-width: 84%; justify-content: center; text-align: center;
  font: italic 7.4cqw/1.15 var(--serif); padding: 4cqw 6.5cqw 4cqw 5cqw; gap: 2.6cqw; border-radius: 3cqw;
  background: rgba(20, 8, 8, .55); border-color: var(--brass); color: var(--gold);
  box-shadow: 0 0 5cqw rgba(240, 207, 142, .22), inset 0 0 0 1px rgba(240, 207, 142, .12);
  transition: opacity .45s ease, transform .45s ease, border-color .2s, box-shadow .2s;
}
.cardback .card-cta::before { font-size: 4.4cqw; }
.cardback .card-cta[disabled] { color: #d9c9a4; border-color: var(--brass-dim); background: rgba(20, 8, 8, .45); }
.draw.mode-stage .cardback .card-cta { opacity: 0; transform: scale(.94); pointer-events: none; }
.draw:not(.mode-stage):not(.mode-party) .stage { cursor: pointer; }
.draw:not(.mode-stage):not(.mode-party) .stage:hover .card-cta:not([disabled]) { border-color: var(--gold); box-shadow: 0 0 7cqw rgba(240, 207, 142, .4); }
.draw:not(.mode-stage):not(.mode-party) .stage { transition: translate .25s ease; }
.draw:not(.mode-stage):not(.mode-party) .stage:hover { translate: 0 -4px; }

/* Recruit button: styled like the scene's reply button */
.recruit-wrap {
  margin-top: calc(var(--lead) + var(--flav-h)); /* plus the flex gap = the card's distance from the top bar */
  display: inline-block;
}
/* the big button (the main call on a screen): a dark chip with gold italic letters, the same in both themes */
.recruit {
  font: var(--big-font); font-size: 1.35rem; color: var(--btn-fg); cursor: pointer; min-height: var(--big-h);
  background: var(--btn-bg); border: 1px solid var(--btn-line); border-radius: var(--big-r);
  padding: 12px 26px 12px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3); transition: border-color .2s, box-shadow .2s, background .2s, transform .1s;
}
.recruit::before { content: "\276F"; font: 400 .95rem/1 var(--sans); color: #c9994a; font-style: normal; }
.recruit:hover { background: var(--btn-bg-hi); border-color: #f0cf8e; box-shadow: 0 4px 22px rgba(240, 207, 142, .25); }
.recruit:active { transform: translateY(1px); }
/* not yet: the outline, greyed (the same for every big button) */
.recruit[disabled], .recruit[disabled]:hover { cursor: default; background: var(--btn2-bg); color: var(--text-dim); border-color: var(--felt-line); box-shadow: none; }
.recruit[disabled]::before { color: var(--text-dim); }

.result { display: grid; gap: 6px; justify-items: center; min-height: 3.2em; }
.result .who { font: 400 1.35rem/1.2 var(--display); color: var(--text); }
.result .what { font-size: .92rem; color: var(--text-dim); }
.result .what b { color: var(--text); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--gold); }
.save-note { font-size: .78rem; color: var(--text-dim); opacity: .8; margin: 0; }

/* the map loading (betaload.js): the old home screen stays out of sight; the map is the game's home */
html.ro-loading:not(.ro-open) :is(#view-draw, #view-roster, #view-leaders, #maint-bar) { visibility: hidden; }
html.ro-loading:has(#boot-error:not([hidden])) body::after { content: none; }
body > :is(.acct, .streak) { display: none !important; } /* (until the Road Out moves them into its bar) */
html.ro-loading:not(.ro-open) body::after { content: "Unrolling the map…"; position: fixed; inset: 0; display: grid; place-items: center; font: italic 1.3rem var(--serif); color: var(--text-dim); pointer-events: none; }
