/* AI Edu LK · base.css v3
   Original styles for our LMS, informed by editorial design principles.
   Mobile-first, heraldic academic. */

@import url('./fonts.css?v=20260719-local');
@import url('./tokens.css?v=20260709-v31');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --wave-f-tap-target: 44px;
  --wave-f-readable-inline: min(100%, 72ch);
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg-page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wf-mobile-safe,
.app-main,
.page,
.widget,
.card,
.panel,
.sheet,
.modal,
.lesson,
.edu-doc,
.t-main {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wf-readable {
  max-width: var(--wave-f-readable-inline);
}

button,
a,
[role="button"],
input,
select,
textarea {
  touch-action: manipulation;
}

table,
pre,
code,
.table-wrap,
.edu-table-wrap {
  max-width: 100%;
}

pre,
code {
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  img,
  video,
  canvas,
  iframe,
  svg {
    max-width: 100%;
  }

  .wf-mobile-safe,
  .app-main,
  .page,
  .widget,
  .card,
  .panel,
  .sheet,
  .modal {
    min-width: 0;
    max-width: 100%;
  }

  button,
  a[role="button"],
  .btn,
  .btn-primary,
  .btn-ghost,
  .btn-text,
  .btn-icon,
  .tab,
  .pill,
  .menu__item {
    min-height: var(--wave-f-tap-target);
  }
}

/* — NUCLEAR blue-tap kill — applies to all clickable surfaces on every browser — */
html, body, *, *::before, *::after {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
  -webkit-tap-highlight-color: transparent !important;
  outline-color: transparent;
}
button, a, [role="button"], [tabindex], label,
.widget, .tab, .menu__item, .file, .entry, .toggle, .row, .card, .pullout,
.btn-square, .lesson, .card-link, .course-tile, .course-card,
.sub-row, .lead, .day-row, .file-row, .lesson-row, .user-row, .lead-card,
button:focus, button:hover, button:active,
a:focus, a:hover, a:active {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none !important;
  outline-color: transparent !important;
  outline-style: none !important;
  -webkit-focus-ring-color: transparent !important;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }

/* default focus also blocked on body */
body:focus, html:focus { outline: none !important; }

/* keyboard a11y — re-enable focus-ring only via :focus-visible, in gold */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
.widget:focus-visible,
.tab:focus-visible,
.menu__item:focus-visible,
.btn-square:focus-visible {
  outline: 1.5px solid var(--accent) !important;
  outline-offset: 3px !important;
  border-radius: 4px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 1.5px solid var(--accent) !important;
  outline-offset: 2px !important;
}
.input:focus-visible, textarea.input:focus-visible { outline: none !important; }

/* Heraldic gold focus-ring for keyboard users only (a11y) */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
.widget:focus-visible,
.tab:focus-visible,
.menu__item:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
}
.input:focus-visible, textarea.input:focus-visible { outline: none; }

/* selection color — brand burgundy, not blue */
::selection { background: rgba(31, 52, 97, 0.20); color: var(--ink); }
::-moz-selection { background: rgba(31, 52, 97, 0.20); color: var(--ink); }

img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: none; border-top: 1px solid var(--hair); margin: 0; }

/* — typography roles — */
.h-display-xl {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(56px, 11vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.h-display {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 56px);
  line-height: 1;
  letter-spacing: -0.02em;
}
.h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}
.h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}
.h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: 0;
}
.italic-display {
  font-family: var(--font-display);
  font-style: normal;
}

.lead {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 20px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.10em;
  color: var(--ink-mute);
}
.eyebrow.gold { color: var(--accent); }
.eyebrow::before {
  content: ''; display: none;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  color: var(--accent);
  font-size: 13px;
}
.eyebrow.no-mark::before { display: none; }

.caption {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-mute);
  line-height: 1.45;
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-size: 13px;
  letter-spacing: -0.005em;
}
.mono-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.mono-mark.accent { color: var(--accent); }

.footnote {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 12px;
  color: var(--ink-mute);
  line-height: 1.55;
}
.footnote .marker {
  font-family: var(--font-mono);
  color: var(--accent);
  font-style: normal;
  margin-right: 4px;
}

/* — drop cap — */
.drop-cap::first-letter {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: normal;
  font-size: 80px;
  line-height: 0.85;
  float: left;
  padding: 6px 12px 0 0;
  color: var(--accent);
}

.text-ink   { color: var(--ink); }
.text-mute  { color: var(--ink-mute); }
.text-faint { color: var(--ink-faint); }
.text-accent { color: var(--accent); }

/* — metric — */
.metric {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: normal;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}
.metric.accent { color: var(--accent); }
.metric-xl { font-size: 96px; }
.metric-lg { font-size: 56px; }
.metric-md { font-size: 40px; }

/* — N° serial mark (Shuka-inspired) — */
.serial {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.serial::before { content: '§ '; opacity: 0.85; }

/* — buttons — */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-button);
  box-shadow: var(--shadow-half);
  transition: background-color var(--t-fast) var(--ease-ui),
              color var(--t-fast) var(--ease-ui),
              border-color var(--t-fast) var(--ease-ui),
              transform var(--t-micro) var(--ease-ui);
  cursor: pointer;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: var(--ink);
    color: var(--bg-page);
  }
}

.btn-primary {
  background: var(--ink);
  color: var(--bg-page);
  border-color: var(--ink);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-page);
  }
}

.btn-text {
  border-color: transparent;
  box-shadow: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--ink);
}
.btn-text:active { transform: none; }
@media (hover: hover) and (pointer: fine) {
  .btn-text:hover {
    background: transparent;
    color: var(--ink);
    border-bottom-color: var(--accent);
  }
}

.btn-ghost {
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-mute);
  padding: 8px 12px;
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover { color: var(--ink); background: var(--bg-soft); }
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-mute);
}
@media (hover: hover) and (pointer: fine) {
  .btn-icon:hover { color: var(--ink); background: var(--bg-soft); }
}

.btn-block { width: 100%; padding: 14px 22px; }

.btn-arrow::after {
  content: ' ↗';
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

/* — inputs (borderless with bottom hairline, tetradka-style) — */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-family: var(--font-body);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  font-weight: 500;
}
.input {
  width: 100%;
  padding: 9px 0 9px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hair);
  color: var(--ink);
  font-size: 16px;
  font-family: var(--font-body);
  transition: border-color var(--t-fast) var(--ease-ui);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}
textarea.input {
  resize: vertical;
  min-height: 96px;
  border: 1px solid var(--hair);
  padding: 14px 16px;
  border-radius: var(--r-input);
  background: var(--bg-canvas);
  line-height: 1.55;
  font-size: 15px;
}
textarea.input:focus { border-color: var(--ink); }

/* — pills (uppercase chip with heraldic tone) — */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.08em;
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-pill);
  color: var(--ink);
  background: transparent;
  white-space: nowrap;
  line-height: 1.5;
  transition: background-color var(--t-fast) var(--ease-ui),
              color var(--t-fast) var(--ease-ui);
}
.pill.accent { border-color: var(--accent); color: var(--accent); }
.pill.moss   { border-color: var(--moss); color: var(--moss); }
.pill.garnet { border-color: var(--garnet); color: var(--garnet); }
.pill.mute   { border-color: var(--hair); color: var(--ink-mute); }
.pill.solid {
  background: var(--ink);
  color: var(--bg-page);
  border-color: var(--ink);
}
@media (hover: hover) and (pointer: fine) {
  a.pill:hover, button.pill:hover {
    background: var(--ink);
    color: var(--bg-page);
  }
}

/* — avatars (ink monogram, Lora initials) — */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-avatar);
  background: var(--bg-canvas);
  border: 1px solid var(--hair);
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--ink);
  font-size: 15px;
  flex-shrink: 0;
  letter-spacing: 0;
  line-height: 1;
}
.avatar-xs { width: 24px; height: 24px; font-size: 11px; }
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 56px; height: 56px; font-size: 22px; }
.avatar-lg { width: 88px; height: 88px; font-size: 36px; border-width: 1.5px; }
.avatar-xl { width: 200px; height: 200px; font-size: 90px; border-width: 1.5px; }
.avatar.me {
  border-color: var(--accent);
  color: var(--accent);
}
.avatar.solid {
  background: var(--accent);
  color: var(--bg-page);
  border-color: var(--accent);
}

/* — cards — */
.card {
  background: var(--bg-canvas);
  border: 1px solid var(--hair);
  border-radius: var(--r-card);
  padding: 24px;
  transition: transform var(--t-fast) var(--ease-enter),
              border-color var(--t-fast) var(--ease-ui),
              box-shadow var(--t-fast) var(--ease-ui);
}
.card-interactive { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .card-interactive:hover {
    transform: translateY(-2px);
    border-color: var(--hair-strong);
    box-shadow: 0 0 0 0.5px var(--hair-strong), 0 4px 14px rgba(26, 20, 16, 0.05);
  }
}

.pullout {
  position: relative;
  padding: 22px 24px;
  background: var(--bg-soft);
  border-radius: var(--r-card);
  border-left: 1px solid var(--accent);
}

/* — progress (hairline + ink + gold dot) — */
.progress {
  position: relative;
  height: 1px;
  background: var(--hair);
}
.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--ink);
  transition: width 600ms var(--ease-enter);
}
.progress-dot {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* — divider — */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 56px 0 22px;
  color: var(--ink-mute);
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hair);
}
.divider .label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.10em;
  color: var(--ink-mute);
}
.divider .glyph {
  font-family: var(--font-display);
  font-style: normal;
  color: var(--accent);
  font-size: 16px;
}

/* — file row — */
.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: baseline;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hair-soft);
  font-size: 14px;
}
.file-row .file-type {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  text-transform: none;
  min-width: 32px;
}
.file-row .file-name { font-family: var(--font-body); color: var(--ink); }
.file-row .file-sz {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.file-row .file-action {
  font-family: var(--font-body);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color var(--t-fast) var(--ease-ui), border-color var(--t-fast) var(--ease-ui);
}
@media (hover: hover) and (pointer: fine) {
  .file-row .file-action:hover { color: var(--ink); border-color: var(--accent); }
}

/* — stagger entrance (emil) — */
.stagger > * {
  opacity: 0;
  transform: translateY(20px);
  animation: enter var(--t-entrance) var(--ease-enter) forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 320ms; }
.stagger > *:nth-child(6) { animation-delay: 400ms; }
.stagger > *:nth-child(7) { animation-delay: 480ms; }
.stagger > *:nth-child(8) { animation-delay: 560ms; }
.stagger > *:nth-child(9) { animation-delay: 640ms; }

@keyframes enter {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* — app shell — */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  position: relative;
}

.app-content {
  flex: 1;
  padding: 32px 24px 130px;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(var(--bg-page-rgb), 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-base) var(--ease-ui);
}
.app-topbar.scrolled { border-bottom-color: var(--hair); }

.back-link {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-mute);
  padding: 8px 4px;
  letter-spacing: 0.04em;
  transition: color var(--t-fast) var(--ease-ui);
}
.back-link::before { content: '↳ '; font-family: var(--font-mono); color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .back-link:hover { color: var(--ink); }
}

/* — tabbar — */
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 16px 24px max(16px, env(safe-area-inset-bottom)) 24px;
  background: rgba(var(--bg-page-rgb), 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hair);
  z-index: 10;
}
.tab {
  display: inline-flex;
  align-items: center;
  padding: 4px 4px 6px;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--ink-mute);
  font-weight: 400;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease-ui), border-color var(--t-fast) var(--ease-ui);
}
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
@media (hover: hover) and (pointer: fine) {
  .tab:not(.active):hover { color: var(--ink); }
}

/* — watermark Φ (heraldic mark in corner of hero) — */
.watermark-phi {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: normal;
  color: var(--accent-watermark);
  pointer-events: none;
  user-select: none;
  font-size: 320px;
  line-height: 0.8;
  letter-spacing: -0.04em;
  top: 12px;
  right: -40px;
  z-index: 0;
}

/* — 12-col grid utility — */
.grid12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: 16px;
}

.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

.start-2 { grid-column-start: 2; }
.start-3 { grid-column-start: 3; }
.start-4 { grid-column-start: 4; }

/* — marginalia (italic side notes) — */
.marginalia {
  font-family: var(--font-display);
  font-style: normal;
  font-size: 13px;
  color: var(--ink-mute);
  line-height: 1.4;
}

/* — toggle — */
.toggle {
  width: 38px;
  height: 22px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  background: transparent;
  transition: background-color var(--t-fast) var(--ease-ui);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform var(--t-fast) var(--ease-ui), background-color var(--t-fast) var(--ease-ui);
}
.toggle.on { background: var(--ink); }
.toggle.on::after { transform: translateX(16px); background: var(--accent); }
.toggle.off { border-color: var(--hair); }
.toggle.off::after { background: var(--ink-faint); }

/* UX acceptance primitives shared by role dashboards */
.ux-action-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: var(--ux-action-min-height);
  padding: 8px 0;
}

.ux-action-strip > button,
.ux-action-strip > a,
.ux-action-strip > [role="button"] {
  min-height: var(--ux-action-min-height);
}

.ux-empty-state {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 96px;
  padding: 18px;
  border: 1px dashed var(--hair);
  border-radius: 8px;
  color: var(--ink-mute);
  text-align: center;
  background: var(--bg-canvas);
}

.ux-danger-zone {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(138, 46, 34, 0.24);
  border-radius: 8px;
  color: var(--ux-danger-ink);
  background: var(--ux-danger-bg);
}

.ux-action-strip :focus-visible,
.ux-empty-state :focus-visible,
.ux-danger-zone :focus-visible {
  box-shadow: var(--ux-focus-ring);
}
