/* Raindle styles.
   Idea: the game is a desk in a dark cargo bay, and the clue is a sheet of paper on it.
   Item mode is a data sheet with the hidden words inked out. Logbook mode is a thermal shipping slip
   (the in-game item lore is literally shipping manifests). The paper is the only light thing on the page,
   so the eye goes there first. All the color elsewhere comes from item tiers and match results. */

@font-face { font-family: "Big Shoulders Display"; src: url("fonts/big-shoulders-display.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/hanken-grotesk.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("fonts/courier-prime-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("fonts/courier-prime-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;

  --bulkhead: #141a20;
  --plating: #1c242c;
  --plating-hi: #27313b;
  --line: #34414c;
  --slip: #dde4e2;
  --slip-shade: #bcc8c5;
  --ink: #11161a;
  --text: #e5ebef;
  --muted: #9aa8b3;
  --focus: #7cc7f2;

  --ok: #2f8553;
  --part: #d9a43a;
  --bad: #2a333c;

  --t-common: #dfe5e8;
  --t-uncommon: #7bd264;
  --t-legendary: #ee5148;
  --t-boss: #ead84e;
  --t-lunar: #62bbf3;
  --t-void: #d88aea;
  --t-equipment: #f59d3d;
  --t-hallowed: #f4d58a;
  --t-hex: #e0768c;
  --t-meal: #e7a77c;
  --t-pages: #a9b6f0;

  --display: "Big Shoulders Display", "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Courier Prime", "Courier New", Courier, monospace;
}

[data-tier] { --tc: var(--muted); }
[data-tier="Common"] { --tc: var(--t-common); }
[data-tier="Uncommon"] { --tc: var(--t-uncommon); }
[data-tier="Legendary"] { --tc: var(--t-legendary); }
[data-tier="Boss"] { --tc: var(--t-boss); }
[data-tier="Lunar"] { --tc: var(--t-lunar); }
[data-tier="Void"] { --tc: var(--t-void); }
[data-tier="Equipment"], [data-tier="Elite Equipment"] { --tc: var(--t-equipment); }
[data-tier="Lunar Equipment"] { --tc: var(--t-lunar); }
[data-tier="Hallowed"] { --tc: var(--t-hallowed); }
[data-tier="Hex"] { --tc: var(--t-hex); }
[data-tier="Meal"] { --tc: var(--t-meal); }
[data-tier="N'tormat Pages"] { --tc: var(--t-pages); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bulkhead);
  color: var(--text);
  font: 400 1rem/1.5 var(--body);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 42rem; margin: 0 auto; padding: 0 1rem; }

/* ---------- masthead ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.25rem; padding-bottom: .5rem; }
.brand { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.mark { margin: 0; font: 800 clamp(2.5rem, 10vw, 3.5rem)/.9 var(--display); text-transform: uppercase; letter-spacing: .01em; }
.dayno { color: var(--muted); font-size: .95rem; }
.tools { display: flex; gap: .25rem; }
.tool { white-space: nowrap; background: none; border: 1px solid transparent; border-radius: 4px; padding: .4rem .65rem; color: var(--muted); font-weight: 600; font-size: .95rem; }
.tool:hover { color: var(--text); border-color: var(--line); }
.blurb { margin: .25rem 0 1.25rem; color: var(--muted); max-width: 60ch; min-height: 3em; }

/* ---------- mode tabs: folder tabs that join the sheet below ---------- */
.tabs { display: flex; gap: .25rem; position: relative; z-index: 1; }
.tab {
  font: 700 1.2rem/1 var(--display);
  letter-spacing: .02em;
  padding: .7rem 1.25rem .6rem;
  background: var(--plating);
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: var(--plating-hi); }
.tab[aria-selected="true"] { background: var(--slip); color: var(--ink); border-color: var(--slip); margin-bottom: -1px; padding-bottom: .7rem; }

/* ---------- the sheet ---------- */
.clue { background: var(--slip); color: var(--ink); border-radius: 0 4px 4px 4px; padding: 1rem 1.5rem 1.6rem; }
.clue-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-bottom: 1px solid var(--slip-shade); padding-bottom: .6rem; margin-bottom: 1.1rem; font-family: var(--body); }
.clue-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.count { font-size: .9rem; font-weight: 600; color: #44525b; }
.clue-body { min-height: 5rem; }
.redacted { margin: 0; font-size: 1.25rem; line-height: 1.75; }

/* inked-out words */
.rd { display: inline-block; height: 1.02em; width: calc(var(--n, 4) * .56em); background: var(--ink); vertical-align: -.17em; border-radius: 1px; }
.wash { animation: develop .9s ease-out both; }
@keyframes develop {
  0%, 55% { background-color: var(--ink); color: transparent; }
  100% { background-color: transparent; color: var(--ink); }
}

/* shipping slip (logbook mode) */
.clue-logbook { --tooth: 24px; padding-bottom: calc(1.6rem + var(--tooth) / 2);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--tooth) 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--tooth) 100%; }
.manifest { font-family: var(--mono); font-size: 1.02rem; line-height: 1.55; }
.mline { margin: 0 0 .5rem; padding-left: 2ch; text-indent: -2ch; overflow-wrap: anywhere; }
.mk { font-weight: 700; }
.manifest .rd { width: calc(var(--n, 4) * 1ch); height: 1.05em; vertical-align: -.2em; }
.mline.hid { height: 1.6rem; display: flex; align-items: center; padding-left: 0; text-indent: 0; }
.lbar { display: block; height: .5rem; width: var(--w, 60%); background: repeating-linear-gradient(90deg, var(--slip-shade) 0 7px, transparent 7px 11px); }

/* ---------- guess input ---------- */
.guess-form { display: flex; gap: .5rem; margin-top: 1.5rem; }
.combo { position: relative; flex: 1; min-width: 0; }
.inp { width: 100%; font-size: 1.05rem; font-weight: 500; color: var(--text); background: var(--plating); border: 1px solid var(--line); border-radius: 4px; padding: .8rem 1rem; }
.inp::placeholder { color: #7f8d98; }
.inp:focus-visible { outline-offset: 0; border-color: var(--focus); }
.btn { font-weight: 700; padding: .8rem 1.3rem; border-radius: 4px; border: 1px solid var(--slip); background: var(--slip); color: var(--ink); }
.btn:hover { background: #fff; border-color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--plating-hi); border-color: var(--line); }

.sugg { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .25rem; list-style: none; background: var(--plating-hi); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 12px 28px rgba(0, 0, 0, .55); max-height: 20rem; overflow-y: auto; }
.opt { display: flex; align-items: center; gap: .65rem; padding: .4rem .5rem; border-radius: 4px; cursor: pointer; }
.opt.active, .opt:hover { background: #34414d; }
.oname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.otier { color: var(--tc); font-size: .85rem; font-weight: 600; }
.sugg-none { padding: .7rem .6rem; color: var(--muted); }

/* ---------- item icons, with a plain tile when the wiki image will not load ---------- */
.ico { --s: 40px; flex: none; position: relative; display: inline-grid; place-items: center; width: var(--s); height: var(--s); background: var(--plating-hi); border: 2px solid var(--tc, var(--muted)); border-radius: 4px; overflow: hidden; }
.ico.xs { --s: 28px; border-width: 1px; }
.ico.sm { --s: 38px; }
.ico.lg { --s: 76px; border-width: 3px; }
.ico img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ico.noimg::after { content: attr(data-i); font: 800 calc(var(--s) * .42)/1 var(--display); color: var(--tc, var(--muted)); text-transform: uppercase; }

/* ---------- guesses ---------- */
.guesses { margin-top: 1.5rem; display: grid; gap: .5rem; }
.empty { margin: 1.5rem 0 0; color: var(--muted); }
.colhead { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: .35rem; margin-left: calc(10.5rem + .5rem); color: var(--muted); font-size: .85rem; font-weight: 600; }
.grow { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr); gap: .5rem; align-items: stretch; }
.gname { display: flex; align-items: center; gap: .6rem; min-width: 0; font-weight: 700; }
.gn { min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.grow:not(:has(.tiles)) { grid-template-columns: minmax(0, 1fr); background: var(--plating); border: 1px solid var(--line); border-radius: 4px; padding: .4rem .6rem; }
.grow:not(:has(.tiles)) .gname { justify-content: flex-start; }
.gmark { margin-left: auto; font-weight: 800; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; font-size: .9rem; }
.gmark.ok { background: var(--ok); color: #fff; }
.gmark.bad { background: var(--bad); color: var(--muted); border: 1px solid var(--line); }
.grow.correct .gn { color: var(--t-uncommon); }

.tiles { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: .35rem; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: center; gap: .1rem; min-height: 3.4rem; padding: .35rem .5rem; border-radius: 4px; font-size: .82rem; font-weight: 700; line-height: 1.2; overflow-wrap: break-word; hyphens: manual; }
.tile .tv { display: flex; flex-direction: column; }
.tile .tg { position: absolute; top: .2rem; right: .35rem; font-size: .75rem; font-weight: 800; opacity: .9; }
.tile.ok { background: var(--ok); color: #fff; }
.tile.part { background: var(--part); color: var(--ink); }
.tile.bad { background: var(--bad); color: #b7c3cc; }
.fresh .tile { animation: stamp .42s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes stamp { from { transform: scaleY(0); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- result ---------- */
.result { margin-top: 1.5rem; padding: 1.1rem 1.25rem; background: var(--plating); border: 1px solid var(--line); border-radius: 6px; }
.rhead { display: flex; gap: 1rem; align-items: center; }
.rline { margin: 0; color: var(--muted); }
.rname { margin: .1rem 0 0; font: 800 clamp(1.9rem, 7vw, 2.6rem)/1 var(--display); letter-spacing: .01em; }
.rname a { color: var(--tc, var(--text)); text-decoration: none; }
.rname a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rmeta { margin: .25rem 0 0; color: var(--muted); font-size: .95rem; }
.rdesc { margin: 1rem 0 0; max-width: 62ch; color: var(--text); }
.ractions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1.1rem; }
.next { margin: 0 0 0 auto; color: var(--muted); font-size: .9rem; }
.next span { font-variant-numeric: tabular-nums; color: var(--text); }

.preview { margin: .75rem 0 0; padding: .5rem .75rem; border: 1px dashed var(--line); border-radius: 4px; color: var(--muted); font-size: .9rem; }
.notice { background: var(--plating); border: 1px solid var(--line); border-radius: 0 6px 6px 6px; padding: 1.25rem 1.5rem; }
.notice h2 { margin: 0 0 .4rem; font: 800 1.6rem/1.1 var(--display); }
.notice p { margin: 0; color: var(--muted); max-width: 55ch; }

/* ---------- dialogs ---------- */
dialog { width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; background: var(--plating); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
dialog::backdrop { background: rgba(8, 11, 14, .72); }
.dlg-in { padding: 1.25rem 1.5rem 1.5rem; }
.dlg-in h2 { margin: 0 0 .75rem; font: 800 1.9rem/1 var(--display); }
.dlg-in h3 { margin: 1.25rem 0 .35rem; font-size: 1rem; }
.dlg-in p { margin: 0 0 .6rem; max-width: 62ch; }
.dlg-in .legend { display: grid; grid-template-columns: 5.5rem 1fr; gap: .5rem .75rem; align-items: center; margin: .75rem 0; }
.dlg-in .legend .tile { min-height: 2.2rem; justify-content: center; }
.dlg-x { margin-top: 1rem; }
.stat-block + .stat-block { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.stat-block h3 { margin: 0 0 .6rem; font: 800 1.35rem/1 var(--display); }
.statrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 0 0 1rem; }
.statrow div { display: flex; flex-direction: column-reverse; }
.statrow dd { margin: 0; font: 800 2rem/1 var(--display); }
.statrow dt { color: var(--muted); font-size: .85rem; }
.dist { display: grid; gap: .25rem; }
.drow { display: grid; grid-template-columns: 1.2rem 1fr; gap: .5rem; align-items: center; font-size: .85rem; }
.dn { color: var(--muted); text-align: right; }
.dbar { display: block; width: var(--p, 0%); min-width: 1.6rem; padding: 0 .4rem; text-align: right; background: var(--plating-hi); border-radius: 2px; color: var(--muted); font-weight: 700; }
.dbar.has { background: var(--ok); color: #fff; }

.foot { margin-top: auto; padding-top: 2.5rem; padding-bottom: 1.5rem; color: var(--muted); font-size: .85rem; }
.foot p { margin: 0; max-width: 60ch; }

/* ---------- narrow screens ---------- */
@media (max-width: 40rem) {
  .tool { padding: .4rem .45rem; }
  .top { gap: .5rem; }
  .clue { padding: .9rem 1.1rem 1.4rem; }
  .redacted { font-size: 1.15rem; }
  .colhead { display: none; }
  .grow { grid-template-columns: minmax(0, 1fr); gap: .35rem; background: var(--plating); border: 1px solid var(--line); border-radius: 6px; padding: .55rem; }
  .grow:not(:has(.tiles)) { padding: .4rem .6rem; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(5.4rem, 1fr)); }
  .tile::before { content: attr(data-col); display: block; font-size: .7rem; font-weight: 600; opacity: .75; margin-bottom: .1rem; }
  .guess-form { flex-direction: row; }
  .result { padding: 1rem; }
  .next { margin-left: 0; width: 100%; }
  .statrow { grid-template-columns: repeat(2, 1fr); }
  .dlg-in { padding: 1rem 1.1rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .wash, .fresh .tile { animation: none; }
}
