/* Розклад Сави. Mobile-first: зошит у клітинку, синя кулькова ручка,
   червона стрілка «зараз» — як поле на берегах зошита. */

:root {
  --paper: #f7f9fd;
  --grid: #e3eaf5;
  --card: #ffffff;
  --ink: #1b2a4a;
  --pen: #2748b8;
  --muted: #62718d;
  --line: #d7e0ee;
  --needle: #e03131;
  --warn-bg: #fff1e0;
  --warn-ink: #b04a00;
  --radius: 12px;

  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1524;
    --grid: #172038;
    --card: #141c2e;
    --ink: #e4eaf6;
    --pen: #93aaff;
    --muted: #93a1bd;
    --line: #27334f;
    --needle: #ff6b6b;
    --warn-bg: #3a2410;
    --warn-ink: #ffb066;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 560px;
  margin-inline: auto;
  padding-inline: 16px;
}

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }

/* ---------- шапка ---------- */

.top { padding-block: 28px 18px; }

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.name {
  font-family: var(--font-hand);
  font-size: 72px;
  font-weight: 700;
  line-height: 0.9;
  color: var(--pen);
  transform: rotate(-2deg);
  transform-origin: left bottom;
  margin-block: 6px 8px;
}

.clock {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- картки ---------- */

main { display: grid; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2,
.section-h {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.section-h { margin-top: 6px; padding-inline: 2px; }

/* ---------- статус ---------- */

.status { margin-bottom: 14px; }

.status-now {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.status-now.is-live::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  vertical-align: 3px;
  border-radius: 50%;
  background: var(--needle);
  animation: pulse 1.6s ease-in-out infinite;
}

.status-next {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--pen);
}

.status-error {
  font-weight: 700;
  color: var(--warn-ink);
}

@keyframes pulse {
  50% { opacity: 0.3; }
}

/* ---------- лінійка ---------- */

.ruler-scale {
  position: relative;
  height: 16px;
}

.tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.ruler-track {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: calc(100% / var(--hours)) 100%;
}

.block {
  position: absolute;
  top: 3px;
  bottom: 3px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--c);
  overflow: hidden;
}

.block.is-done { opacity: 0.35; }

.needle {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  margin-left: -1px;
  background: var(--needle);
  border-radius: 1px;
}

.needle::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--needle);
}

.ruler-today { margin-bottom: 16px; }
.ruler-today .ruler-track { height: 44px; }
.ruler-today .block { font-size: 18px; }

.ruler-week {
  display: grid;
  grid-template-columns: 2.2em 1fr;
  gap: 7px 8px;
  align-items: center;
}

.ruler-week .ruler-track { height: 20px; border-radius: 6px; }
.ruler-week .block { top: 3px; bottom: 3px; border-radius: 3px; }
.ruler-week .needle { top: -3px; bottom: -3px; }
.ruler-week .needle::before { display: none; }

.ruler-day {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.ruler-day.is-today { color: var(--needle); }

/* ---------- заняття ---------- */

.lessons { display: grid; }

.lesson {
  display: grid;
  grid-template-columns: 3.4em 1fr;
  column-gap: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--c);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--c) 9%, var(--card));
}

.lesson-time {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.t-start { font-size: 18px; font-weight: 800; line-height: 1.1; }
.t-end { font-size: 13px; font-weight: 600; color: var(--muted); }

.lesson-what {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 10px;
}

.lesson-name { font-size: 17px; font-weight: 700; }

.lesson-note {
  font-family: var(--font-hand);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
  color: var(--pen);
}

.lesson-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.lesson.is-now { background: color-mix(in srgb, var(--c) 20%, var(--card)); }
.lesson.is-now .lesson-meta { color: var(--needle); font-weight: 800; }
.lesson.is-done { opacity: 0.5; }

.gap {
  margin-left: 1px;
  padding: 7px 14px;
  border-left: 2px dashed var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.gap.is-tight {
  border-left-color: var(--warn-ink);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-weight: 800;
}

.gap.is-tight::before { content: "⚠ "; }

/* ---------- тиждень ---------- */

.ruler-week + .totals { margin-top: 16px; }

.totals { display: grid; }

.total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 15px;
}

.total-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }

.total-note {
  font-family: var(--font-hand);
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
  color: var(--pen);
}

.total-name::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}

.total-value { margin-left: auto; color: var(--muted); font-weight: 600; white-space: nowrap; }

.total.is-sum { border-bottom: 0; }
.total.is-sum .total-name::before { display: none; }
.total.is-sum .total-value { color: var(--ink); font-weight: 800; }

/* ---------- по днях ---------- */

.days { display: grid; gap: 10px; }

.day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
}

.day.is-today { border: 2px solid var(--needle); }

.day-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.day-h h3 { font-size: 17px; font-weight: 800; }

.today-tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--needle);
  color: var(--card);
  font-size: 12px;
  font-weight: 800;
}

.day-empty {
  font-family: var(--font-hand);
  font-size: 24px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- підвал ---------- */

.foot {
  padding-block: 22px 28px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .status-now.is-live::before { animation: none; }
}
