/* ------------------------------------------------------------------
   Pi — The Game  ·  stylesheet
   Palette matches the iOS app: mint-teal primary on a light background
   with white surfaces, dark teal ink for text, and a coral accent for
   errors (matching the "Game Over" red in the app).
------------------------------------------------------------------ */

:root {
  /* Brand — mint teal sampled from the app icon & screenshots */
  --mint-50:  #f0faf6;
  --mint-100: #dff3ec;
  --mint-200: #b7e6d6;
  --mint-300: #7fd6b9;
  --mint-400: #56c8a1;
  --mint-500: #4ec9a8;  /* primary brand */
  --mint-600: #3aa98b;  /* hover / accent */
  --mint-700: #2b8069;  /* deep accent, link color */
  --mint-800: #1e5e4d;

  /* Neutral "ink" scale — dark teal-tinted greys for a light theme */
  --bg:        #fafdfc;  /* page background */
  --surface:   #ffffff;  /* cards, modals */
  --surface-2: #f4faf8;  /* tinted raised surface */
  --border:    #e2edea;  /* hairlines */
  --border-2:  #cfe0db;  /* stronger borders */
  --text:      #0e2b24;  /* primary text */
  --text-2:    #3d5a54;  /* secondary text */
  --text-3:    #70877f;  /* muted text */
  --coral:     #e9574f;  /* error / Game Over accent */

  --shadow-sm: 0 1px 2px rgba(30, 94, 77, 0.08);
  --shadow:    0 10px 30px -12px rgba(30, 94, 77, 0.18);
  --shadow-lg: 0 40px 80px -30px rgba(30, 94, 77, 0.25);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius:    14px;
  --radius-lg: 22px;
  --max:       1120px;

  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(78, 201, 168, 0.18), transparent 60%),
    radial-gradient(800px 500px at -10% 20%, rgba(78, 201, 168, 0.10), transparent 60%);
  min-height: 100vh;
}

a { color: var(--mint-700); text-decoration: none; }
a:hover { color: var(--mint-600); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 0.4em;
  line-height: 1.1;
}
h1 { font-size: clamp(2.2rem, 5vw + 1rem, 4.4rem); }
h2 { font-size: clamp(1.8rem, 3vw + 1rem, 3rem); }
h3 { font-size: 1.5rem; }
p  { margin: 0 0 1em; color: var(--text-2); }
code {
  font-family: var(--font-mono);
  background: var(--mint-50);
  color: var(--mint-700);
  padding: 0.15em 0.4em;
  border-radius: 6px;
  font-size: 0.92em;
  border: 1px solid var(--mint-100);
}
pre { font-family: var(--font-mono); }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.2rem; color: var(--text); }
.brand .mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 4px 12px -4px rgba(46, 168, 138, 0.4);
  display: block;
}
.site-nav { display: none; gap: 4px; font-size: 14px; }
.site-nav a { color: var(--text-2); padding: 8px 12px; border-radius: 999px; }
.site-nav a:hover { color: var(--mint-700); background: var(--mint-50); }
@media (min-width: 820px) { .site-nav { display: flex; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; padding: 12px 22px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; font-size: 15px;
  transition: all 0.15s ease; font-family: inherit;
  text-decoration: none;
}
.btn-primary {
  background: var(--mint-500); color: #fff;
  box-shadow: 0 10px 24px -10px rgba(58, 169, 139, 0.55);
}
.btn-primary:hover { background: var(--mint-600); color: #fff; transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { border-color: var(--mint-500); color: var(--mint-700); background: var(--mint-50); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin-top: 8px; color: var(--text); }

/* ---------- hero ---------- */
.hero { padding: 80px 0 40px; }
.hero-grid { display: grid; gap: 48px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.2fr 1fr; } }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-2); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--text-2);
  box-shadow: var(--shadow-sm);
}
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--mint-500); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.hero h1 { margin-top: 18px; color: var(--text); line-height: 0.95; }
.hero h1 .pi { color: var(--mint-500); }
.hero p.lead { font-size: 1.125rem; max-width: 36em; color: var(--text-2); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 28px; }
.hero-note { font-size: 13px; color: var(--text-3); margin-top: 12px; }

/* App Store screenshot framed like a phone */
.hero-shot { display: flex; justify-content: center; }
.hero-shot img {
  width: 100%;
  max-width: 320px;
  height: auto;
  aspect-ratio: 800 / 1422;
  border-radius: 38px;
  border: 1px solid var(--border);
  padding: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

/* Screenshot gallery on /app/ */
.shot-gallery {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 8px;
}
.shot-gallery img {
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 1422;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.shot-gallery img:hover { transform: translateY(-4px); border-color: var(--mint-500); box-shadow: var(--shadow-lg); }

.rating-row {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--text-2);
  margin-top: 12px;
}
.rating-row .stars { color: var(--mint-500); letter-spacing: 2px; font-size: 16px; }

/* ---------- sections ---------- */
.section { padding: 64px 0; }
.section h2 { text-align: center; }
.section .lead { text-align: center; max-width: 40em; margin: 12px auto 0; color: var(--text-2); }

.feature-grid { display: grid; gap: 20px; margin-top: 40px; }
@media (min-width: 720px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .feature-grid { grid-template-columns: repeat(3, 1fr); } }
.feature .icon { font-size: 28px; }
.feature h3 { margin: 10px 0 6px; color: var(--text); font-family: var(--font-display); }
.feature p { font-size: 14px; color: var(--text-2); margin: 0; }

/* The big promo panel on the homepage */
.panel {
  border-radius: 26px;
  border: 1px solid var(--mint-200);
  background:
    linear-gradient(135deg, var(--mint-500), var(--mint-600));
  color: #fff;
  padding: clamp(28px, 5vw, 56px);
  display: grid; gap: 40px;
  box-shadow: var(--shadow);
}
.panel h2, .panel p { color: #fff; }
.panel p { color: rgba(255, 255, 255, 0.9); }
@media (min-width: 820px) { .panel { grid-template-columns: 1fr 1fr; align-items: center; } }
.link-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 14px; }
.link-grid a {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 14px;
  border-radius: 14px;
  color: #fff;
  backdrop-filter: blur(4px);
  transition: all 0.15s ease;
}
.link-grid a:hover { background: rgba(255, 255, 255, 0.2); border-color: #fff; color: #fff; }

.cta-panel {
  text-align: center;
  border: 1px solid var(--mint-200);
  background: var(--mint-50);
  border-radius: 26px;
  padding: clamp(32px, 5vw, 64px);
}
.cta-panel h2 { color: var(--text); }
.cta-panel .lead { color: var(--text-2); }
.cta-panel .hero-actions { justify-content: center; }

/* ---------- Apple's official App Store badge ---------- */
.app-store-badge {
  display: inline-block;
  line-height: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.app-store-badge:hover { transform: translateY(-1px); opacity: 0.9; }
.app-store-badge img {
  display: block;
  height: 48px;
  width: auto;
}

/* ---------- footer ---------- */
.site-footer { margin-top: 96px; border-top: 1px solid var(--border); background: var(--surface-2); }
.footer-grid { display: grid; gap: 36px; padding: 56px 0; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.site-footer h4 { font-family: var(--font-sans); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin: 0 0 12px; font-weight: 600; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 14px; }
.site-footer ul a { color: var(--text-2); }
.site-footer ul a:hover { color: var(--mint-700); }
.footer-legal { border-top: 1px solid var(--border); }
.footer-legal .container { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; padding: 24px; font-size: 12px; color: var(--text-3); }

/* ---------- long-form content (prose) ---------- */
.prose { max-width: 42rem; margin: 0 auto; }
.prose h2 { margin-top: 48px; color: var(--text); }
.prose h3 { margin-top: 32px; color: var(--text); }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1em; }
.prose li { margin: 6px 0; color: var(--text-2); }
.prose a { text-decoration: underline; text-decoration-color: var(--mint-300); text-underline-offset: 3px; }
.prose blockquote {
  border-left: 3px solid var(--mint-500);
  padding-left: 18px;
  margin: 20px 0;
  color: var(--text-2);
  font-style: italic;
}

/* page title block */
.page-head { padding: 56px 0 24px; text-align: center; }
.page-head .eyebrow { text-transform: uppercase; letter-spacing: 0.18em; color: var(--mint-600); font-size: 12px; font-weight: 700; }
.page-head h1 { margin-top: 14px; color: var(--text); }
.page-head p { max-width: 40em; margin: 16px auto 0; color: var(--text-2); }

/* ---------- calculators ---------- */
.calc form { display: grid; gap: 16px; }
.calc label { display: block; font-size: 13px; color: var(--text-3); margin-bottom: 6px; font-weight: 500; }
.calc input[type="number"], .calc input[type="text"], .calc select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.calc input:focus, .calc select:focus { outline: none; border-color: var(--mint-500); box-shadow: 0 0 0 4px rgba(78, 201, 168, 0.15); }
.calc .row { display: flex; gap: 8px; align-items: stretch; }
.calc .row > input,
.calc .row > select {
  width: auto;          /* override the 100% rule above */
  min-width: 0;         /* let flex actually shrink the item */
}
.calc .row > input  { flex: 1 1 0; }
.calc .row > select { flex: 0 0 auto; padding-right: 40px; }
.calc .toggle { display: flex; gap: 8px; }
.calc .toggle label { flex: 1; margin: 0; }
.calc .toggle input { position: absolute; opacity: 0; pointer-events: none; }
.calc .toggle span {
  display: block; text-align: center; padding: 10px 14px;
  border: 1px solid var(--border-2); border-radius: 12px; cursor: pointer;
  color: var(--text-2);
  background: var(--surface);
  transition: all 0.15s ease;
}
.calc .toggle input:checked + span { border-color: var(--mint-500); color: var(--mint-700); background: var(--mint-50); }
.calc .result {
  border: 1px solid var(--mint-200);
  background: var(--mint-50);
  border-radius: 14px;
  padding: 20px;
}
.calc .result .label { font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.calc .result .value { font-family: var(--font-mono); font-size: 28px; color: var(--mint-700); margin-top: 4px; word-break: break-all; font-weight: 600; }
.calc .result .steps { margin-top: 10px; font-family: var(--font-mono); font-size: 13px; color: var(--text-2); }

/* ---------- digits viewer ---------- */
.digit-viewer { padding: 24px; }
.digit-viewer .header { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.digit-viewer .header .status { font-size: 13px; color: var(--text-3); }
.digit-viewer .header .controls { display: flex; align-items: center; gap: 8px; }
.digit-viewer .header input[type="number"] {
  width: 110px; background: var(--surface); border: 1px solid var(--border-2);
  color: var(--text); padding: 6px 10px; border-radius: 10px;
  font-family: var(--font-mono); font-size: 13px;
}
.digit-viewer .digits {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  max-height: 60vh;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre;
  color: var(--text);
  tab-size: 2;
}
.digit-viewer .digits::-webkit-scrollbar { height: 10px; width: 10px; }
.digit-viewer .digits::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; }
.digit-viewer .digits::-webkit-scrollbar-thumb:hover { background: var(--mint-400); }
.digit-viewer .footer { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-3); margin-top: 12px; gap: 12px; flex-wrap: wrap; }

/* ---------- the /play game ---------- */
.game { max-width: 680px; margin: 0 auto; }
.game .scoreline { display: flex; justify-content: space-between; margin-bottom: 24px; }
.game .scoreline .label { font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.game .scoreline .streak { font-family: var(--font-display); font-size: 56px; color: var(--mint-500); line-height: 1; font-weight: 700; }
.game .scoreline .best { font-family: var(--font-display); font-size: 32px; color: var(--text); line-height: 1; font-weight: 600; }
.game .digit-box {
  background: var(--mint-50);
  border: 1px solid var(--mint-200);
  border-radius: 14px;
  padding: 22px;
  min-height: 120px;
}
.game .digit-box .label { font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; font-weight: 600; }
.game .digit-box .text { font-family: var(--font-mono); font-size: 22px; line-height: 1.6; color: var(--text); word-break: break-all; }
.game .digit-box .text .wrong-digit {
  color: var(--coral);
  font-weight: 700;
  text-decoration: line-through;
  text-decoration-color: rgba(233, 87, 79, 0.6);
}
.game .digit-box .text .future {
  color: var(--mint-600);
  opacity: 0.45;
}
.game .keypad button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.game .keypad button:disabled:hover { background: var(--surface); transform: none; }
.game .msg { text-align: center; font-size: 14px; color: var(--text-2); min-height: 22px; margin: 14px 0; }
.game .keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 360px; margin: 0 auto; user-select: none; }
.game .keypad button {
  background: var(--surface);
  border: 2px solid var(--mint-500);
  color: var(--mint-700);
  border-radius: 999px;
  aspect-ratio: 1 / 1;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: var(--shadow-sm);
}
.game .keypad button:hover { background: var(--mint-50); transform: translateY(-1px); }
.game .keypad button:active { background: var(--mint-500); color: #fff; transform: translateY(1px); }
.game .controls { margin-top: 20px; display: flex; justify-content: center; gap: 12px; }
.game .tip { margin-top: 14px; text-align: center; font-size: 12px; color: var(--text-3); }
.kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); border-radius: 4px; font-family: var(--font-mono); font-size: 11px; }

/* Error / Game Over accent from the app */
.game .msg.error { color: var(--coral); font-weight: 600; }

/* ---------- quiz ---------- */
.quiz { max-width: 600px; margin: 0 auto; }
.quiz .q { font-size: 20px; color: var(--text); margin-bottom: 18px; font-family: var(--font-display); font-weight: 600; }
.quiz .options { display: grid; gap: 10px; }
.quiz .options button {
  text-align: left;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.quiz .options button:hover { border-color: var(--mint-500); background: var(--mint-50); }
.quiz .options button.correct { border-color: var(--mint-500); background: var(--mint-50); color: var(--mint-700); font-weight: 600; }
.quiz .options button.wrong { border-color: var(--coral); background: #fdf0ef; color: var(--coral); }
.quiz .status { text-align: center; color: var(--text-2); margin: 20px 0 0; }
.quiz .status .explain {
  margin-top: 10px;
  padding: 16px 18px;
  background: var(--mint-50);
  border: 1px solid var(--mint-200);
  border-radius: 14px;
  text-align: left;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}
.quiz .status .explain strong { color: var(--text); }
.quiz .status .explain sup { font-size: 0.7em; vertical-align: super; }
.quiz .meta { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 20px; }

/* ---------- a11y + utilities ---------- */
.skip-link { position: absolute; left: -9999px; top: auto; }
.skip-link:focus { position: fixed; left: 12px; top: 12px; z-index: 60; background: var(--mint-500); color: #fff; padding: 10px 16px; border-radius: 10px; }

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); }
