/* ============================================================
   The Cricket Boundary Almanac — shared styles
   ============================================================ */

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

:root {
  /* surfaces — cool, neutral, professional */
  --paper:    #f3f6f9;
  --paper-2:  #e7edf2;
  --paper-3:  #ffffff;
  --rule:     #dde4ea;
  --rule-2:   #c2cccf;

  /* ink — slate near-black */
  --ink:      #0f1822;
  --ink-2:    #45525f;
  --ink-3:    #7a8896;
  --ink-4:    #aab6c1;

  /* data scale + brand spot */
  --ball:     #de342a;   /* the red ball — identity spot */
  --turf:     #0e9f6e;   /* green — sixes likely / good for batting */
  --rust:     #e08a2e;   /* amber — hard / bowler's ground */
  --gold:     #b8862a;
  --accent:   #2f6fed;   /* cool blue — primary interactive */

  /* type */
  --serif: 'Archivo', system-ui, -apple-system, sans-serif;   /* display + big stat numerals */
  --sans:  'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --mono:  ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Forced-light theme (overrides OS dark preference) */
[data-paper="light"] {
  --paper:   #f3f6f9;
  --paper-2: #e7edf2;
  --paper-3: #ffffff;
  --rule:    #dde4ea;
  --rule-2:  #c2cccf;
  --ink:     #0f1822;
  --ink-2:   #45525f;
  --ink-3:   #7a8896;
  --ink-4:   #aab6c1;
  --ball:    #de342a;
  --turf:    #0e9f6e;
  --rust:    #e08a2e;
  --accent:  #2f6fed;
}

/* Dark dashboard theme */
[data-paper="ink"] {
  --paper:   #0e141b;
  --paper-2: #161f29;
  --paper-3: #1a232e;
  --rule:    #28323d;
  --rule-2:  #3a4654;
  --ink:     #e8edf2;
  --ink-2:   #aab6c2;
  --ink-3:   #71808e;
  --ink-4:   #4a5663;
  --ball:    #f0564b;
  --turf:    #2ac483;
  --rust:    #f0a04a;
  --accent:  #5a93ff;
}

/* Honour OS preference unless user overrode */
@media (prefers-color-scheme: dark) {
  :root:not([data-paper]) {
    --paper:   #0e141b;
    --paper-2: #161f29;
    --paper-3: #1a232e;
    --rule:    #28323d;
    --rule-2:  #3a4654;
    --ink:     #e8edf2;
    --ink-2:   #aab6c2;
    --ink-3:   #71808e;
    --ink-4:   #4a5663;
    --ball:    #f0564b;
    --turf:    #2ac483;
    --rust:    #f0a04a;
    --accent:  #5a93ff;
  }
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  font-feature-settings: "ss01", "kern";
  text-rendering: optimizeLegibility;
}

body > * { position: relative; z-index: 1; }

a { color: inherit; }

/* ============================================================
   MASTHEAD
   ============================================================ */

.masthead {
  border-bottom: 1px solid var(--ink);
  padding-top: 18px;
}

.masthead-strap {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin: 0 auto;
  max-width: 1240px;
  padding-left: 24px;
  padding-right: 24px;
}
.masthead-strap span { color: var(--ink-4); margin: 0 6px; }
.masthead-strap em { font-style: normal; color: var(--ink-2); font-weight: 700; }

.masthead-title {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 24px 22px;
  text-align: center;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(3rem, 7vw, 4.6rem);
  letter-spacing: -0.04em;
  line-height: 0.92;
  color: var(--ink);
}
.wordmark .ball {
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: var(--ball);
  position: relative;
  vertical-align: baseline;
  margin-left: 0.04em;
  transform: translateY(-0.04em);
  box-shadow: inset -0.1em -0.08em 0 0 rgba(0,0,0,0.18), inset 0.1em 0.08em 0 0 rgba(255,255,255,0.12);
}
.wordmark .ball::after {
  content: "";
  position: absolute;
  top: 18%; left: 18%;
  width: 36%; height: 36%;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
}

.masthead-tagline {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  color: var(--ink-2);
  margin-top: 12px;
  letter-spacing: 0;
}

.masthead-nav {
  border-top: 1px solid var(--rule);
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: center;
  gap: 28px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.masthead-nav a { text-decoration: none; transition: color 0.15s; }
.masthead-nav a:hover { color: var(--accent); }
.masthead-nav a.current { color: var(--ink); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

/* ============================================================
   SECTION HEADERS — chapter-break style
   ============================================================ */

.chapter-break {
  display: flex;
  align-items: baseline;
  gap: 14px;
  max-width: 1240px;
  margin: 56px auto 24px;
  padding: 0 24px;
}
.chapter-break::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  align-self: center;
}
.chapter-break .chapter-mark {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.chapter-break .chapter-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* eyebrow used in cards/sections */
.eyebrow {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================
   STANDFIRST (editorial intro)
   ============================================================ */

.standfirst {
  max-width: 1240px;
  margin: 28px auto 0;
  padding: 0 24px;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.55;
  color: var(--ink-2);
  letter-spacing: 0;
  text-align: left;
}
.standfirst p:first-child::first-letter {
  font: inherit;
  float: none;
  margin: 0;
  color: inherit;
}
.standfirst p + p { margin-top: 0.7em; }
.standfirst strong { color: var(--ink); font-weight: 600; }

/* ============================================================
   FOOTER
   ============================================================ */

.colophon {
  margin-top: 96px;
  border-top: 1px solid var(--ink);
  padding-top: 28px;
}
.colophon-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 40px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
}
.colophon h4 {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.colophon p + p { margin-top: 6px; }
.colophon a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
.colophon a:hover { text-decoration-color: var(--accent); color: var(--accent); }
.colophon .colophon-rule {
  border-top: 1px solid var(--rule);
  max-width: 1240px;
  margin: 0 auto 16px;
  padding-top: 16px;
}
.colophon-foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.colophon-foot .ball-mini {
  display: inline-block;
  width: 0.7em; height: 0.7em;
  border-radius: 50%;
  background: var(--ball);
  margin: 0 0.3em;
  vertical-align: -0.05em;
}

@media (max-width: 800px) {
  .colophon-inner { grid-template-columns: 1fr; gap: 22px; }
  .colophon-foot { flex-direction: column; gap: 8px; text-align: center; }
}

/* ============================================================
   COMMON: links, focus, buttons, etc
   ============================================================ */

a.inline-link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s, color 0.15s;
}
a.inline-link:hover {
  text-decoration-color: var(--accent);
  color: var(--accent);
}

.btn-plain {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 9px 16px;
  background: var(--paper-3);
  color: var(--ink);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-plain:hover { background: var(--ink); color: var(--paper); }

.btn-ghost {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 7px 14px;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-ghost.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* tabular numerals everywhere they matter */
.tabular { font-variant-numeric: tabular-nums; }

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

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

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  z-index: 999;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  font-family: var(--sans);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   TWEAKS PANEL
   ============================================================ */

.tweaks-toggle {
  position: fixed;
  bottom: 18px; right: 18px;
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper-3);
  border: none;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(15,24,34,0.22);
  font-family: var(--sans);
  font-style: normal;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: transform 0.15s;
}
.tweaks-toggle:hover { transform: translateY(-2px); }

.tweaks-panel {
  position: fixed;
  bottom: 74px; right: 18px;
  width: 280px;
  background: var(--paper-3);
  border: 1px solid var(--rule-2);
  border-radius: 12px;
  z-index: 99;
  padding: 18px 20px 20px;
  font-family: var(--sans);
  font-size: 13px;
  display: none;
  box-shadow: 0 16px 40px rgba(15,24,34,0.18);
}
.tweaks-panel.open { display: block; }
.tweaks-panel h5 {
  font-family: var(--sans);
  font-weight: 700;
  font-style: normal;
  font-size: 13px;
  letter-spacing: 0.01em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}
.tweak-row { margin-bottom: 14px; }
.tweak-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.tweak-options { display: flex; gap: 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.tweak-options button {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--rule);
  padding: 7px 4px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink-2);
  transition: all 0.15s;
}
.tweak-options button:last-child { border-right: none; }
.tweak-options button:hover { background: var(--paper-2); }
.tweak-options button.active { background: var(--ink); color: var(--paper); }
