/* ==========================================================================
   teacher/app.css — the teacher-tools product's own design system.

   Deliberately NOT the personal site's base.css tokens (no borrowed blue/
   red/purple theme switcher, no dark glass panels) — this is its own
   product with its own identity: warm paper and chalkboard, not another
   dark dashboard with a gradient hero. Light by default; dark mode follows
   the system automatically (no manual switcher — one less thing to decide
   the first time someone opens this).

   Every animation here respects prefers-reduced-motion, same convention
   core.js already uses for JS-driven motion elsewhere in this codebase.
   ========================================================================== */

:root {
  --paper: #f6f1e4;
  --paper-raised: #fffcf4;
  --paper-sunken: #ece4d1;
  --ink: #2b2420;
  --ink-dim: #6b5f52;
  --ink-mute: #9c9183;
  --line: rgba(43, 36, 32, 0.14);
  --line-strong: rgba(43, 36, 32, 0.26);

  --chalk: #2f5c4c;
  --chalk-soft: #4a7d68;
  --chalk-deep: #1f4536;
  --chalk-contrast: #fdfaf3;
  --chalk-wash: rgba(47, 92, 76, 0.09);
  --chalk-line: rgba(47, 92, 76, 0.3);

  --warn: #a8431c;
  --warn-wash: rgba(168, 67, 28, 0.1);
  --ok: #2f5c4c;
  --ok-wash: rgba(47, 92, 76, 0.1);

  --shadow-sm: 0 1px 2px rgba(43, 36, 32, 0.06);
  --shadow-md: 0 6px 16px -4px rgba(43, 36, 32, 0.14);
  --shadow-lg: 0 18px 40px -12px rgba(43, 36, 32, 0.2);

  --r-sm: 0.4rem;
  --r-md: 0.7rem;
  --r-lg: 1.1rem;

  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 2.75rem;
  --sp-8: 4rem;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms;
  --t-med: 260ms;
  --t-slow: 420ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1c1813;
    --paper-raised: #26211a;
    --paper-sunken: #14110d;
    --ink: #f1e9d8;
    --ink-dim: #c7bba3;
    --ink-mute: #8d8270;
    --line: rgba(241, 233, 216, 0.14);
    --line-strong: rgba(241, 233, 216, 0.26);

    --chalk: #7fc2a4;
    --chalk-soft: #9bd3bb;
    --chalk-deep: #5ea585;
    --chalk-contrast: #0e1a14;
    --chalk-wash: rgba(127, 194, 164, 0.14);
    --chalk-line: rgba(127, 194, 164, 0.36);

    --warn: #e07a4e;
    --warn-wash: rgba(224, 122, 78, 0.16);
    --ok: #7fc2a4;
    --ok-wash: rgba(127, 194, 164, 0.14);
  }
}

/* --------------------------------------------------------------------------
   Reset + base
   -------------------------------------------------------------------------- */

.tt {
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  /* A faint paper grain, drawn with nothing but gradients — no image
     request, no CSP exception needed. Barely visible; it's the
     difference between "flat" and "something you'd hold". */
  background-image:
    radial-gradient(circle at 20% 20%, rgba(43, 36, 32, 0.025) 0, transparent 45%),
    radial-gradient(circle at 80% 60%, rgba(43, 36, 32, 0.02) 0, transparent 40%);
}

.tt * {
  box-sizing: border-box;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--chalk);
  color: var(--chalk-contrast);
  border-radius: 0 0 var(--r-sm) 0;
  font-weight: 650;
}

.skip-link:focus {
  left: 0;
}

.tt h1, .tt h2, .tt h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0;
}

.tt a {
  color: inherit;
}

.tt-wrap {
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

.tt-wrap--narrow {
  max-width: 30rem;
}

/* --------------------------------------------------------------------------
   Motion — entrance
   -------------------------------------------------------------------------- */

@keyframes tt-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tt-rise {
  animation: tt-rise var(--t-slow) var(--ease) both;
}

.tt-rise[data-d="1"] { animation-delay: 70ms; }
.tt-rise[data-d="2"] { animation-delay: 140ms; }
.tt-rise[data-d="3"] { animation-delay: 210ms; }

@media (prefers-reduced-motion: reduce) {
  .tt-rise { animation: none; opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.tt-header {
  position: sticky;
  top: 0;
  z-index: 20;
  /* A solid fallback first, same reasoning screen.css documents for
     avoiding color-mix(): a browser that doesn't support it would drop
     the whole declaration below, leaving a transparent header over
     scrolling content rather than merely a less-blurred one. */
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.tt-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding-block: var(--sp-3);
}

.tt-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  flex-shrink: 0;
}

.tt-brand__mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-sm);
  background: var(--chalk);
  color: var(--chalk-contrast);
  transform: rotate(-4deg);
  transition: transform var(--t-med) var(--ease);
}

.tt-brand:hover .tt-brand__mark {
  transform: rotate(2deg) scale(1.06);
}

.tt-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  flex: 1;
}

.tt-nav__link {
  position: relative;
  text-decoration: none;
  color: var(--ink-dim);
  font-weight: 600;
  font-size: 0.92rem;
  padding-block: 0.3rem;
}

.tt-nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -1px;
  height: 2px;
  background: var(--chalk);
  border-radius: 2px;
  transition: right var(--t-med) var(--ease);
}

.tt-nav__link:hover,
.tt-nav__link.is-active {
  color: var(--ink);
}

.tt-nav__link:hover::after,
.tt-nav__link.is-active::after {
  right: 0;
}

@media (prefers-reduced-motion: reduce) {
  .tt-nav__link::after { transition: none; }
}

.tt-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

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

.tt-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: inherit;
  font-weight: 650;
  font-size: 0.92rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.tt-btn:active {
  transform: translateY(1px) scale(0.98);
}

.tt-btn--primary {
  background: var(--chalk);
  color: var(--chalk-contrast);
  box-shadow: var(--shadow-sm);
}

.tt-btn--primary:hover {
  background: var(--chalk-deep);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tt-btn--ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.tt-btn--ghost:hover {
  border-color: var(--chalk-line);
  background: var(--chalk-wash);
}

.tt-btn--sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.tt-btn--lg {
  padding: 0.8rem 1.4rem;
  font-size: 1rem;
}

.tt-btn--block {
  width: 100%;
  justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
  .tt-btn { transition: background var(--t-fast) linear; }
  .tt-btn:active, .tt-btn--primary:hover { transform: none; }
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.tt-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease),
              border-color var(--t-med) var(--ease);
}

.tt-card--link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--chalk-line);
}

@media (prefers-reduced-motion: reduce) {
  .tt-card { transition: border-color var(--t-fast) linear; }
  .tt-card--link:hover { transform: none; }
}

.tt-card__title {
  font-size: 1.15rem;
  margin: 0 0 0.3rem;
}

.tt-card__tagline {
  color: var(--ink-dim);
  margin: 0;
  font-size: 0.94rem;
}

.tt-grid {
  display: grid;
  gap: var(--sp-5);
}

.tt-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 42rem) {
  .tt-grid--2 { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.tt-hero {
  padding-block: clamp(3rem, 8vw, 5.5rem) clamp(2rem, 6vw, 3.5rem);
  position: relative;
  overflow: hidden;
}

.tt-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 var(--sp-3);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--chalk-wash);
  color: var(--chalk-deep);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tt-hero__eyebrow { color: var(--chalk-soft); }
}

.tt-hero__title {
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  max-width: 24ch;
  margin-top: 0;
}

.tt-hero__lead {
  margin-top: var(--sp-4);
  max-width: 44ch;
  color: var(--ink-dim);
  font-size: 1.1rem;
}

.tt-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

/* A scattering of chalk-dust specks drifting up behind the hero text.
   Pure CSS, no image, no JS — a handful of dots with staggered drift
   animations. Entirely decorative, so it is the one thing dropped
   outright under reduced motion rather than just slowed down. */
.tt-dust {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.tt-dust span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--chalk);
  opacity: 0.22;
  animation: tt-drift 9s ease-in-out infinite;
}

@keyframes tt-drift {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-22px) translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .tt-dust { display: none; }
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.tt-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-dim);
}

.tt-field input {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  padding: 0.65rem 0.8rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.tt-field input:focus {
  outline: none;
  border-color: var(--chalk);
  box-shadow: 0 0 0 3px var(--chalk-wash);
}

.tt-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}

/* --------------------------------------------------------------------------
   Flash messages
   -------------------------------------------------------------------------- */

@keyframes tt-flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tt-flash {
  padding: 0.7rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: var(--sp-3);
  animation: tt-flash-in var(--t-med) var(--ease) both;
}

.tt-flash--error { background: var(--warn-wash); color: var(--warn); }
.tt-flash--success { background: var(--ok-wash); color: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  .tt-flash { animation: none; }
}

/* --------------------------------------------------------------------------
   Section / misc
   -------------------------------------------------------------------------- */

.tt-section {
  padding-block: var(--sp-7);
}

.tt-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.tt-section__title {
  font-size: 1.6rem;
}

.tt-page-title {
  font-size: 2rem;
  margin-bottom: var(--sp-5);
}

.tt-dim {
  color: var(--ink-dim);
}

.tt-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.tt-table th, .tt-table td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.tt-table th {
  color: var(--ink-mute);
  font-weight: 650;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  background: var(--paper-sunken);
}

.tt-table tr:last-child td {
  border-bottom: none;
}

.tt-code {
  font-family: "JetBrains Mono", monospace;
  background: var(--paper-sunken);
  padding: 0.15rem 0.45rem;
  border-radius: 0.3rem;
  font-size: 0.88em;
}

.tt-footer {
  padding-block: var(--sp-6);
  border-top: 1px solid var(--line);
  color: var(--ink-mute);
  font-size: 0.85rem;
}
