/*
  Shikshak Sahyog — design tokens
  Source of truth: design-brief.md ("Chalk & Circuit"). Every page includes
  this file first so colour/type/spacing stay identical everywhere.
*/

:root {
  /* Palette */
  --ink: #151A2D;
  --surface: #F7F8FC;
  --card: #FFFFFF;
  --primary: #4338CA;
  --primary-bright: #6366F1;
  --accent: #F59E0B;
  --accent-pink: #EC4899;
  --teal: #14B8A6;
  --danger: #EF4444;
  --muted: #6B7280;
  --line: #E5E7EB;

  --grad: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
  --shadow: 0 1px 3px rgba(21, 26, 45, .08), 0 8px 24px rgba(21, 26, 45, .04);

  /* Resource-type spine colours (design-brief §Signature elements) */
  --spine-lesson-plan: var(--primary);
  --spine-teaching-resource: var(--teal);
  --spine-worksheet: var(--accent-pink);

  /* Type scale (rem) */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.75rem;

  /* 8px spacing grid */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  --radius-card: 16px;
  --radius-control: 10px;
  --radius-pill: 20px;

  color-scheme: light;
}

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

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-base);
  line-height: 1.5;
}

h1, h2, h3, h4, .disp, .stat .val, .score, .badge {
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
}

h1, h2, h3, h4 { line-height: 1.15; margin: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Visible keyboard focus rings everywhere (quality floor requirement) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

button { font-family: inherit; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-h {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.card-h h3 { font-size: var(--fs-md); font-weight: 600; }
.card-h a { font-size: var(--fs-xs); color: var(--primary); font-weight: 600; }

.card-b { padding: var(--sp-2) var(--sp-6) var(--sp-5); }

.btn {
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-control);
  padding: 10px 18px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { box-shadow: 0 4px 14px rgba(67, 56, 202, .3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
}
.btn-secondary:hover { box-shadow: none; border-color: var(--primary); }

.btn-danger { background: var(--danger); }

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

.field { margin-bottom: var(--sp-5); }
.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.field .hint { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-1); }
.field .error { font-size: var(--fs-xs); color: var(--danger); margin-top: var(--sp-1); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=search], select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-family: inherit;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }

.checkbox-row { display: flex; align-items: flex-start; gap: var(--sp-2); }
.checkbox-row input { margin-top: 3px; }
.checkbox-row label { font-size: var(--fs-sm); font-weight: 400; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  display: inline-block;
}
.tag-lesson_plan { background: #EEF2FF; color: #4338CA; }
.tag-teaching_resource { background: #E0F7F3; color: #0F766E; }
.tag-worksheet_assessment { background: #FCE7F3; color: #BE185D; }

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--grad);
  color: #fff;
}

.stars { color: var(--accent); font-size: var(--fs-sm); letter-spacing: 1px; }

.toast-region {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 1000;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-control);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}
.toast.success { border-left: 4px solid var(--teal); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, #eef0f5 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: skeleton-shine 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes skeleton-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-5);
  color: var(--muted);
}
.empty-state h4 { color: var(--ink); margin-bottom: var(--sp-2); }
.empty-state p { margin-bottom: var(--sp-4); font-size: var(--fs-sm); }

.alert {
  border-radius: var(--radius-control);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
}
.alert-error { background: #FEF2F2; color: #B91C1C; border: 1px solid #FCA5A5; }
.alert-success { background: #ECFDF5; color: #047857; border: 1px solid #6EE7B7; }
.alert-info { background: #EEF2FF; color: #3730A3; border: 1px solid #C7D2FE; }

dialog { border: none; padding: 0; }
dialog::backdrop { background: rgba(21, 26, 45, .55); backdrop-filter: blur(2px); }
