/*
 * Grimwilder — base styles and design tokens (the night-table direction).
 * Propshaft serves every file in app/assets/stylesheets (alphabetical), so
 * tokens live here and components in components.css. The app is dark-only.
 * Templates and components use only these variables, never literal colors.
 */

/* Self-hosted fonts, SIL Open Font License (app/assets/fonts/OFL-*.txt). */
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/spectral-latin-500-normal-1877a613.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/spectral-latin-700-normal-408cf572.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 500; font-display: swap; src: url("/assets/spectral-latin-500-italic-b2cf6356.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/ibm-plex-sans-latin-400-normal-64251e64.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/ibm-plex-sans-latin-500-normal-290aaea2.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/ibm-plex-sans-latin-600-normal-99b2fa32.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/ibm-plex-mono-latin-500-normal-3f7bbac1.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/ibm-plex-mono-latin-600-normal-b71798d4.woff2") format("woff2"); }

:root {
  color-scheme: dark;

  /* Ground and surfaces */
  --bg: #14130f;
  --surface: #1e1c16;
  --surface-2: #27241d;
  --rail: #1a1813;
  --line: #383428;
  --line-soft: #2c2920;
  --line-strong: #4a4536;

  /* Text */
  --text: #eee7d6;
  --text-soft: #cfc6b0;
  --muted: #b0a791;
  --dim: #8f8774;

  /* Primary action */
  --ember: #e8834a;
  --ember-ink: #1b120b;
  --ember-soft: #2a1d14;
  --link: #f0a274;

  /* Roll results. Disaster isn't in the night-table palette; it's the one
     result outside it, kept distinct from suspense's purple. */
  --perfect: #9cc47a;
  --messy: #e6b450;
  --grim: #f2a093;
  --grim-ring: #e06a5b;
  --grim-bg: #2a1c1a;
  --grim-line: #5a2e28;
  --harm: #8a3a30;
  --disaster: #e58ab0;
  --not-line: #8a5a6e; /* the trait and desire you aren't: a muted rose, apart from the grim reds */

  /* Meta-currencies */
  --spark: #e6b450;
  --thread: #8fc0e8;
  /* Your own chat lines: a cool tint against the warm surfaces incoming lines use. */
  --mine-bg: #1b2631;
  --mine-line: #34506a;
  --suspense: #b88ce6;
  --suspense-text: #c9a8ec;
  --suspense-bg: #1f1a24;
  --suspense-line: #4a3a5a;

  /* Presence halos on the rail's faces: at the table and in use, or open but idle. */
  --presence-active: #6fcf8a;
  --presence-idle: #e6b450;

  /* Type */
  --font-display: "Spectral", Georgia, serif;
  --font-ui: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --font-dice: "IBM Plex Mono", ui-monospace, monospace;

  /* Shape */
  --radius-card: 14px;
  --radius-control: 10px;
  --radius-sm: 6px;
  --tap: 44px;
  --focus: var(--thread);
  --shadow: 0 1px 0 rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.8);

  /* Rhythm */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --measure: 62ch;
  --page: 80rem;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.005em;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 5vw, 2.5rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 var(--space-4); }

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--text); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button,
input,
select,
textarea { font: inherit; }

input,
select,
textarea { color: var(--text); }

/* Selects are drawn here, not by the browser (Safari and macOS would ignore
   most of this otherwise): a dark field with a chevron in our colors, drawn
   with two gradients so it can use the tokens. */
select {
  --chevron: var(--muted);
  appearance: none;
  -webkit-appearance: none;
  min-height: var(--tap);
  padding: var(--space-2) 2.5rem var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--chevron) 50%),
    linear-gradient(135deg, var(--chevron) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px);
  background-size: 6px 6px;
  background-repeat: no-repeat;
  line-height: 1.3;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms;
}

select option,
select optgroup { background: var(--surface); color: var(--text); }

@media (hover: hover) {
  select:hover:not(:disabled) { --chevron: var(--text); border-color: var(--text-soft); box-shadow: inset 0 0 0 1px var(--text-soft); }
}

select:focus-visible { --chevron: var(--text); }
select:disabled { opacity: 0.6; cursor: not-allowed; }

small { font-size: 0.8em; color: var(--dim); }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  padding: var(--space-2) var(--space-3);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip-link:focus { top: var(--space-2); }

.icon { flex: none; vertical-align: middle; }

/* ---------- Shell: header ---------- */

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
}

.brand:hover { color: var(--text); }
.brand__mark { flex: none; }
.brand__d6 { fill: var(--ember); stroke: var(--bg); stroke-width: 22; paint-order: stroke; }
.brand__pips { fill: var(--ember-ink); }
.brand__d8 { fill: var(--grim-ring); }
.brand__d8--shade { opacity: 0.7; }
.brand__d8-number { fill: var(--bg); font-family: var(--font-dice); font-weight: 600; font-size: 112px; }

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.01em;
}

/* "Beta" beside the wordmark while the toolkit is still settling. */
.brand__beta {
  margin-left: -2px;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--ember) 55%, transparent);
  border-radius: var(--radius-sm);
  background: var(--ember-soft);
  color: var(--ember);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}


.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  flex: 1 1 100%;
  order: 4;
}

/* Phones: wordmark and account on one row, then the tabs. */
.brand { order: 1; }
.account { order: 2; margin-left: auto; }

/* Signed in: the beta's warning. On a phone it's a row of its own under the
   wordmark; wider, it sits just before the account button. */
.reset-notice {
  order: 3;
  flex: 1 1 100%;
  margin: 0;
  text-align: center;
  padding: 6px 12px;
  border: 1px solid var(--ember);
  border-radius: var(--radius-sm);
  background: var(--ember-soft);
  color: var(--ember);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

@media (min-width: 48rem) {
  .tabs { order: 3; flex: 1 1 auto; }
  .reset-notice { order: 4; flex: none; }
  .account { order: 4; }
}

.tabs__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

.tabs__link:hover { color: var(--text); }
/* The campaign you're in, by name: cut short if it's long. */
.tabs__name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs__link[aria-current="page"],
.tabs__link--current {
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--ember);
}

/* A tab with a menu: "My characters" when a player has several seated here. */
.tab-menu { position: relative; }
.tab-menu__button { gap: var(--space-1); cursor: pointer; list-style: none; }
.tab-menu__button::-webkit-details-marker { display: none; }
.tab-menu[open] .tab-menu__button .icon { transform: rotate(180deg); }

.tab-menu__menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(22rem, calc(100vw - 2rem));
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tab-menu__menu a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

.tab-menu__menu a:hover { background: var(--surface-2); }
.tab-menu__menu a[aria-current="page"] { font-weight: 600; }

.tabs__link--soon { color: var(--dim); cursor: default; }
.tabs__link--soon:hover { color: var(--dim); }

.account {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.account:hover { color: var(--text); border-color: var(--line-strong); }

.account--signin {
  width: auto;
  padding: 0 var(--space-4);
  border-radius: var(--radius-control);
}

/* ---------- Shell: live banner ---------- */

.live-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--ember-soft);
  color: var(--text-soft);
  text-decoration: none;
}

.live-banner:hover { color: var(--text); }

.live-banner__now {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: 600;
}

.live-banner__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ember) 25%, transparent);
}

.live-banner__where { flex: 1 1 auto; }
.live-banner__go { color: var(--link); font-weight: 600; }

/* ---------- Layout ---------- */

.site-main {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.site-main {
  flex: 1;
  padding-block: var(--space-6) var(--space-7);
}

/* The fluid page: the main column and a rail that drops below it on a phone. */
.fluid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-5);
}

.fluid__main { flex: 999 1 640px; min-width: 0; }
.fluid__rail { flex: 1 1 340px; max-width: 420px; min-width: 0; }

@media (max-width: 47.99rem) {
  .fluid__rail { max-width: none; }
}

/* Full width, like the header: the toolkit's links on the left, the legal notice on the right. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-6);
  padding: var(--space-5) var(--space-4);
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 0.85rem;
}

.site-footer p { margin: 0; }

/* Wide enough: two equal halves, the notice right-aligned in its own. */
@media (min-width: 48rem) {
  .site-footer { display: grid; grid-template-columns: 1fr 1fr; }
  .site-footer p { text-align: right; }
}
.site-footer a { color: inherit; }

.site-footer__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__tools a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

@media (min-width: 48rem) {
  .app-header,
  .live-banner { padding-inline: var(--space-6); }

  .site-main,
  .site-footer { padding-inline: var(--space-6); }
}

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