/* ==========================================================================
   Casihub — a reference on ten casino games

   Designed dark-first: the subject is a room at night. A light variant is
   fully supported and the toggle in the masthead switches between them.

   The page has no photography at all, so type, spacing and one gold accent do
   all the work. Two signatures: the cover's contents grid, which turns 106,000
   characters into something you can enter at any point, and the numbered rail
   that tracks where you are once you are reading.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg:        #0b0b0e;
  --bg-2:      #101014;
  --surface:   #16161b;
  --surface-2: #1c1c22;
  --line:      #26262f;
  --line-2:    #34343f;
  --text:      #ece7dd;
  --text-2:    #a29c8f;
  --text-3:    #6e695f;
  --gold:      #e3b44b;
  --gold-soft: rgba(227, 180, 75, 0.14);

  --display: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --measure: 66ch;
  --rail: 14rem;
  --wrap: 74rem;
  --pad: clamp(1.15rem, 4vw, 3rem);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg:        #fbf9f4;
  --bg-2:      #f4f0e6;
  --surface:   #ffffff;
  --surface-2: #f7f3ea;
  --line:      #e3dccd;
  --line-2:    #cec4b0;
  --text:      #17161a;
  --text-2:    #57525c;
  --text-3:    #857f76;
  --gold:      #9a6d12;
  --gold-soft: rgba(154, 109, 18, 0.12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg:        #fbf9f4;
    --bg-2:      #f4f0e6;
    --surface:   #ffffff;
    --surface-2: #f7f3ea;
    --line:      #e3dccd;
    --line-2:    #cec4b0;
    --text:      #17161a;
    --text-2:    #57525c;
    --text-3:    #857f76;
    --gold:      #9a6d12;
    --gold-soft: rgba(154, 109, 18, 0.12);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  /* Sticky footer — see topothelake; kept identical in behaviour, not in code. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.99rem + 0.32vw, 1.1875rem);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 60;
  background: var(--gold);
  color: #14120c;
  padding: 0.8rem 1.3rem;
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 600;
}
.skip:focus { left: 0; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-inline: var(--pad);
}

/* --- masthead ---------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Prose scrolling underneath must not read through the bar. */
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.85rem;
}
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.wordmark__dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
  transform: translateY(-0.1rem);
}
.masthead__tag {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme:hover { color: var(--gold); border-color: var(--gold); }
.theme svg { width: 1rem; height: 1rem; fill: currentColor; }
.theme__moon { display: none; }
:root[data-theme='light'] .theme__moon { display: block; }
:root[data-theme='light'] .theme__sun { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme__moon { display: block; }
  :root:not([data-theme]) .theme__sun { display: none; }
}

/* --- cover ------------------------------------------------------------- */

.cover {
  position: relative;
  padding-block: clamp(3.5rem, 9vw, 7.5rem) clamp(2.5rem, 5vw, 4rem);
  overflow: hidden;
}
/* A single warm bloom behind the title, instead of a photograph. */
.cover::before {
  content: '';
  position: absolute;
  inset: -30% 20% auto -10%;
  height: 42rem;
  background: radial-gradient(ellipse at 30% 40%, var(--gold-soft), transparent 62%);
  pointer-events: none;
}
.cover__inner { position: relative; max-width: 54rem; }

.cover__eyebrow {
  margin: 0 0 1.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
.cover__title {
  font-family: var(--display);
  font-size: clamp(3.4rem, 1.6rem + 7.4vw, 8rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.045em;
  margin: 0 0 1.5rem;
  text-wrap: balance;
}
.cover__lead {
  max-width: 46ch;
  margin: 0 0 2.4rem;
  font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
  line-height: 1.55;
  color: var(--text-2);
}

.cover__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 2.5rem;
  list-style: none;
  margin: 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--line);
}
.cover__stat { display: flex; flex-direction: column; gap: 0.15rem; }
.cover__num {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.cover__unit {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* --- contents grid: the way into a very long document ------------------ */

.contents { padding-bottom: clamp(3rem, 7vw, 5.5rem); }
.contents__label {
  margin: 0 0 1.1rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
}
.contents__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}
.tile {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  height: 100%;
  padding: 1.05rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.tile:hover {
  border-color: var(--gold);
  background: var(--surface-2);
  transform: translateY(-2px);
}
.tile__num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.tile__name {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile:hover { transform: none; }
}

/* --- reading shell ----------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 0 clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding-bottom: 6rem;
  border-top: 1px solid var(--line);
  padding-top: 3.5rem;
}

.index {
  position: sticky;
  top: 5.5rem;
  align-self: start;
}
.index__label {
  margin: 0 0 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.index__list { list-style: none; margin: 0; padding: 0; }

.index__link {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  align-items: baseline;
  gap: 0.2rem;
  padding: 0.32rem 0 0.32rem 0.75rem;
  margin-left: -0.75rem;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--text-2);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.index__num {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.index__text {
  font-family: var(--display);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.3;
}
.index__link:hover { color: var(--text); }
.index__link.is-current { color: var(--gold); border-left-color: var(--gold); }
.index__link.is-current .index__num { color: var(--gold); }
@media (prefers-reduced-motion: reduce) { .index__link { transition: none; } }

/* --- the document ------------------------------------------------------ */

.doc { max-width: var(--measure); }

.chapter { scroll-margin-top: 5.5rem; }
.chapter--opening { margin-bottom: 1rem; }
.chapter--opening .doc__p:first-of-type {
  font-size: 1.2em;
  line-height: 1.6;
  color: var(--text);
}

.chapter__rule {
  height: 1px;
  background: linear-gradient(90deg, var(--gold), var(--line) 45%, transparent);
  margin: 4.5rem 0 1.3rem;
}
.chapter__ord {
  font-family: var(--mono);
  font-size: 0.5em;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  margin-right: 0.7em;
  vertical-align: 0.36em;
}
.chapter__title {
  font-family: var(--display);
  font-size: clamp(1.9rem, 1.4rem + 1.8vw, 2.6rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.032em;
  margin: 0 0 1.2rem;
  text-wrap: balance;
}

.doc__h3 {
  font-family: var(--display);
  font-size: 1.28rem;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.018em;
  margin: 2.6rem 0 0.7rem;
}
.doc__h4 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.006em;
  margin: 1.9rem 0 0.45rem;
}
.doc__h5 {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 1.6rem 0 0.4rem;
}

.doc__p { margin: 0 0 1.2rem; }

.doc__list { margin: 0 0 1.35rem; padding-left: 1.3rem; }
.doc__list li { margin-bottom: 0.45rem; }
.doc__list li::marker { color: var(--gold); }

/* Runs of numbered tips act as sub-headings for the paragraph beneath. */
.doc__list--num {
  margin: 2rem 0 0.5rem;
  padding-left: 0;
  list-style: none;
  counter-reset: none;
}
.doc__list--num li {
  position: relative;
  margin: 0;
  padding-left: 2.6rem;
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 650;
  letter-spacing: -0.012em;
}
.doc__list--num li::before {
  content: counter(list-item);
  position: absolute;
  left: 0;
  top: 0.05em;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--gold);
}

.doc__quote {
  margin: 1.8rem 0;
  padding: 0.2rem 0 0.2rem 1.3rem;
  border-left: 2px solid var(--gold);
  color: var(--text-2);
}

.doc a { color: var(--gold); text-underline-offset: 0.18em; }

/* --- colophon ---------------------------------------------------------- */

.colophon {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding-block: 3rem;
}
.colophon__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.75rem 3rem;
}
.colophon__name {
  margin: 0 0 0.3rem;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.colophon__note { margin: 0; color: var(--text-2); font-size: 0.95rem; max-width: 34ch; }
.colophon__small {
  margin: 0;
  max-width: 46ch;
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.8;
  color: var(--text-3);
}
.colophon__top {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 0.2rem;
  align-self: flex-end;
}
.colophon__top:hover { color: var(--gold); border-bottom-color: var(--gold); }

/* --- entrance ---------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(12px);
    animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  .reveal--1 { animation-delay: 0.05s; }
  .reveal--2 { animation-delay: 0.12s; }
  .reveal--3 { animation-delay: 0.19s; }
  .reveal--4 { animation-delay: 0.26s; }
  @keyframes rise {
    to { opacity: 1; transform: none; }
  }
}

/* --- narrow viewports --------------------------------------------------
   Eleven chapters stacked vertically swallowed half a phone screen, so the
   rail becomes a one-line sticky scroll strip that still tracks position.
   ----------------------------------------------------------------------- */

@media (max-width: 62rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 0;
    border-top: 0;
  }
  .index {
    position: sticky;
    top: 3.55rem;
    z-index: 30;
    margin: 0 calc(var(--pad) * -1) 2.25rem;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(14px);
    border-block: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 0.85rem;
  }
  .index__label {
    flex: none;
    margin: 0;
    padding: 0.65rem 0 0.65rem var(--pad);
    border-bottom: 0;
    font-size: 0.58rem;
  }
  .index__list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0.15rem;
    padding: 0.45rem var(--pad) 0.45rem 0;
  }
  .index__list::-webkit-scrollbar { display: none; }
  .index__link {
    grid-template-columns: auto auto;
    gap: 0.4rem;
    white-space: nowrap;
    border-left: 0;
    border-bottom: 2px solid transparent;
    margin-left: 0;
    padding: 0.15rem 0.5rem;
  }
  .index__link.is-current { border-left-color: transparent; border-bottom-color: var(--gold); }
  html { scroll-padding-top: 7rem; }
  .chapter { scroll-margin-top: 7rem; }
}

@media (max-width: 40rem) {
  .masthead__tag { display: none; }
  .contents__grid { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
  .cover__stats { gap: 1rem 2rem; }
}
