/* ============================================================
   mathroom — shared design system
   Fonts are NOT loaded here: each page keeps its own
   <link rel="preconnect"> + Google Fonts <link> in <head>,
   so this file has something to apply itself to as soon as
   it parses. Every page should link:
     https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap

   Per-app accent: each page sets ONE line to pick its topic
   color, e.g.  :root { --accent: var(--accent-3); }
   Numbers and Operations -> --accent-1 (blue)
   Geometry               -> --accent-3 (green)
   Algebra                -> --accent-2 (red)
   Statistics/Probability -> --accent-4 (purple)
============================================================ */

:root {
  --black:      #0d0d0d;
  --grey-900:   #1a1a1a;
  --grey-700:   #444;
  --grey-400:   #999;
  --grey-200:   #e8e8e8;
  --grey-100:   #f4f4f4;
  --white:      #ffffff;

  --accent-1:   #2563eb;   /* blue   — Numbers and Operations */
  --accent-2:   #e63946;   /* red    — Algebra */
  --accent-3:   #16a34a;   /* green  — Geometry */
  --accent-4:   #7c3aed;   /* purple — Statistics and Probability */

  --accent:     var(--accent-1);          /* per-page override */
  --accent-red: rgba(220, 38, 38, 0.75);  /* fixed decorative red, independent of topic accent */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; height: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--white);
  color: var(--black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- nav ---------- */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3rem;
  height: 60px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--grey-200);
}

.nav-logo {
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--black);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-back {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--grey-400);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-back:hover { color: var(--black); }

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}
.nav-links a {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--grey-700);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--black); }

.nav-back svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s;
}
.nav-back:hover svg { transform: translateX(-3px); }

/* ---------- page header (per-app intro block) ---------- */
.page-header {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 3.5rem 3rem 2rem;
  animation: fadeUp 0.5s ease both;
}

.page-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-label::before {
  content: '';
  display: inline-block;
  width: 24px; height: 1px;
  background: var(--accent);
}

.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.page-desc {
  font-size: 0.9rem;
  color: var(--grey-400);
  font-weight: 300;
  max-width: 560px;
  line-height: 1.65;
}

/* short competency-style learning-objective line, under the description */
.page-objective {
  display: flex;
  gap: 10px;
  align-items: baseline;
  max-width: 560px;
  margin-top: 1rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--grey-700);
}
.page-objective-label {
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-400);
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--grey-200);
  padding: 1.5rem 3rem;
  background: var(--grey-100);
  margin-top: auto;
}
.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-bottom p {
  font-size: 0.75rem;
  color: var(--grey-400);
  font-family: 'DM Mono', monospace;
}

/* ---------- shared affordance utility ----------
   Applied to DOM-based interactive controls (buttons, range
   inputs, real SVG handles) so "clickable/draggable" stays
   unambiguous under a flat visual style. Canvas-drawn controls
   (geoboard pins, etc.) need their own JS-driven hover/active
   drawing state instead — this class can't reach into canvas. */
.affordance {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.affordance:hover   { transform: scale(1.06); }
.affordance:active  { transform: scale(0.96); }
.affordance:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Landing-page gallery (index.html only)
============================================================ */
header {
  padding: 7rem 3rem 5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  animation: fadeUp 0.6s ease both;
}

.hero-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-1);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-label::before {
  content: '';
  display: inline-block;
  width: 28px; height: 1px;
  background: var(--accent-1);
}

h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(3rem, 6vw, 5.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--black);
  max-width: 720px;
  margin-bottom: 2rem;
}
h1 em { font-style: italic; color: var(--grey-400); }

.hero-body {
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--grey-700);
  max-width: 540px;
  font-weight: 300;
}

.hero-rule {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  position: absolute;
  right: 3rem;
  top: 7rem;
  width: 160px;
  opacity: 0.18;
}
.hero-rule span {
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--black);
}

.gallery-section {
  padding: 3rem 3rem 6rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  border-top: 1px solid var(--grey-200);
  padding-top: 2rem;
}
.section-title {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-400);
}
.section-count {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--grey-200);
}

.category-group { margin-bottom: 3rem; }
.category-group:last-child { margin-bottom: 0; }

.category-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--black);
  margin-bottom: 1rem;
}
.category-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--card-accent, var(--accent-1));
  flex-shrink: 0;
}
.category-count {
  font-weight: 400;
  color: var(--grey-400);
  letter-spacing: 0.04em;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.app-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--white);
  border: 1px solid var(--grey-200);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: fadeUp 0.5s ease both;
}
.app-card:hover { border-color: var(--grey-400); box-shadow: 0 6px 20px rgba(13,13,13,0.08); }
.app-card:hover .card-arrow { opacity: 1; transform: translate(0, 0); }
.app-card:hover .card-thumb img { transform: scale(1.03); }
.app-card:hover .card-accent-bar { width: 100%; }

.c1 { --card-accent: var(--accent-1); }
.c2 { --card-accent: var(--accent-2); }
.c3 { --card-accent: var(--accent-3); }
.c4 { --card-accent: var(--accent-4); }

.card-accent-bar {
  position: absolute;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: var(--card-accent, var(--accent-1));
  transition: width 0.35s ease;
  z-index: 2;
}

.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--grey-100);
  flex-shrink: 0;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.4s ease;
  opacity: 0.95;
  display: block;
}

.card-content {
  padding: 1.5rem 1.5rem 1.1rem;
  background: var(--white);
  display: flex;
  flex-direction: column;
}

.card-tag-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.card-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey-400);
  border: 1px solid var(--grey-200);
  border-radius: 3px;
  padding: 2px 6px;
}
.card-mode-badge svg {
  width: 10px; height: 10px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.card-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.35rem;
  color: var(--black);
  line-height: 1.2;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* description shows as a hover/focus reveal over the thumbnail,
   instead of a fixed line on the card (avoids clipping at any
   card width, and any length of copy is fine) */
.card-tooltip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(13,13,13,0.86);
  color: var(--white);
  font-size: 0.85rem;
  line-height: 1.55;
  font-weight: 300;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.app-card:hover .card-tooltip,
.app-card:focus-visible .card-tooltip {
  opacity: 1;
}

.card-arrow {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 32px; height: 32px;
  border: 1px solid var(--grey-200);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translate(-6px, 6px);
  transition: opacity 0.25s, transform 0.25s;
  background: white;
  z-index: 3;
}
.card-arrow svg {
  width: 14px; height: 14px;
  stroke: var(--black);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-card.placeholder { pointer-events: none; opacity: 0.4; }
.placeholder .card-title { color: var(--grey-400); }

/* impressum / privacy modal (index.html only) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  max-width: 560px;
  width: 100%;
  padding: 3rem;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}
.modal p, .modal address {
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--grey-700);
  font-style: normal;
  margin-bottom: 1rem;
}
.modal-close {
  position: absolute;
  top: 1.25rem; right: 1.25rem;
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer;
  color: var(--grey-400);
  line-height: 1;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--black); }

.btn-link {
  background: none; border: none; padding: 0;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--grey-400);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--black); }

/* ---------- responsive ---------- */
@media (max-width: 700px) {
  nav { padding: 0 1.5rem; }
  header, .gallery-section, .page-header, main, footer { padding-left: 1.5rem; padding-right: 1.5rem; }
  h1 { font-size: 2.6rem; }
  .hero-rule { display: none; }
  footer { padding-top: 1.5rem; padding-bottom: 1.5rem; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}
