/* Mathify — a sheet of graph paper with the app's violet ink on it.
   Light like the app, dark when the device asks for it. */
:root {
  color-scheme: light dark;

  --paper: #f5f5fa;
  --paper-deep: #ecebf7;
  --card: #ffffff;
  --grid: rgba(108, 93, 211, 0.07);
  --grid-major: rgba(108, 93, 211, 0.12);

  --ink: #17162b;
  --ink-dim: #5f5c78;
  --ink-faint: #8f8ca6;

  --violet: #6c5dd3;
  --violet-hi: #8b7cff;
  --violet-lo: #5b4fe0;
  --orange: #ff7a45;

  --line: #e3e1f0;
  --line-strong: #cfcbe8;
  --shadow: 0 18px 40px -22px rgba(76, 64, 170, 0.45);

  --display: 'Sora', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --shell: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f0e1d;
    --paper-deep: #0a0915;
    --card: #17162b;
    --grid: rgba(139, 124, 255, 0.06);
    --grid-major: rgba(139, 124, 255, 0.11);
    --ink: #eeedf8;
    --ink-dim: #b0adc9;
    --ink-faint: #7d7a98;
    --violet: #9d90ff;
    --line: #2a2843;
    --line-strong: #3a3760;
    --shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html, body { overflow-x: clip; }

body {
  min-height: 100vh;
  background-color: var(--paper);
  /* Graph paper: a fine grid every 24px, a stronger line every 120px. */
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.shell { max-width: var(--shell); margin: 0 auto; padding-inline: 20px; }

a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 3px;
}

/* ---- Top bar ----------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow); }

/* ---- Language picker --------------------------------------------------- */

.lang { position: relative; }
.lang-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 600 0.86rem/1 var(--body);
  cursor: pointer;
  box-shadow: 0 6px 18px -14px rgba(76, 64, 170, 0.6);
  transition: border-color 150ms ease;
}
.lang-button:hover, .lang-button[aria-expanded="true"] { border-color: var(--line-strong); }
.lang-button .chev { color: var(--violet); transition: transform 150ms ease; }
.lang-button[aria-expanded="true"] .chev { transform: rotate(180deg); }

.flag {
  display: block;
  flex: none;
  width: 22px;
  height: 15px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(23, 22, 43, 0.14);
}

.lang-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 196px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 22px 44px -18px rgba(23, 22, 43, 0.45);
}
.lang-list[hidden] { display: none; }
.lang-list:focus { outline: none; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 0.9rem;
  cursor: pointer;
}
.lang-option.active { background: rgba(108, 93, 211, 0.1); }
.lang-option[aria-selected="true"] { color: var(--violet); font-weight: 700; }
.lang-option .tick { margin-left: auto; color: var(--violet); visibility: hidden; }
.lang-option[aria-selected="true"] .tick { visibility: visible; }

/* ---- Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 14px 22px;
  border-radius: 16px;
  border: 1px solid transparent;
  font: 700 0.98rem/1.1 var(--body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.btn svg { flex: none; }
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--violet-hi), var(--violet-lo));
  box-shadow: 0 14px 30px -12px rgba(91, 79, 224, 0.65);
}
.btn-primary:hover { box-shadow: 0 18px 36px -12px rgba(91, 79, 224, 0.8); }

.btn-ghost {
  color: var(--ink);
  background: var(--card);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-ghost svg { color: var(--orange); }

.store-text { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.store-kicker { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.82; }
.store-name { font-size: 1.08rem; }

/* ---- Footer ------------------------------------------------------------ */

footer {
  margin-top: clamp(40px, 8vh, 72px);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  padding-block: 26px 34px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.footer-links a { color: var(--violet); font-size: 0.9rem; font-weight: 600; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.copyright { color: var(--ink-faint); font-size: 0.84rem; }

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