/* KBW Stundenplan — standalone web (matches lib/main.dart theme:
   background #121212, surface #1E1E1E, primary #2196F3). */

:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --primary: #2196f3;
  --edge: #90caf9;
  --divider: #333333;
  --text: #ffffff;
  --text-70: rgba(255, 255, 255, 0.7);
  --text-54: rgba(255, 255, 255, 0.54);
  --text-38: rgba(255, 255, 255, 0.38);
  --red: #ff5252;
  --orange: #ffb74d;
  --radius: 12px;
  --card-radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
}

[hidden] { display: none !important; }

/* ---------- Splash ---------- */

#splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  padding: 24px;
  text-align: center;
  transition: opacity 0.35s ease;
}

#splash.done { opacity: 0; pointer-events: none; }

#splash .app-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(33, 150, 243, 0.35);
}

#splash h1 { margin: 8px 0 0; font-size: 20px; font-weight: 700; }
#splash .subtitle { margin: 0; font-size: 12px; color: var(--text-38); }

#splash .spinner {
  width: 22px;
  height: 22px;
  margin-top: 10px;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#splash .hint {
  max-width: 460px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--divider);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-70);
}

.demo-banner b { display: inline; margin-right: 8px; }

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

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 8px 8px 0;
  padding-top: calc(8px + env(safe-area-inset-top));
}

.appbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 56px;
}

.iconbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex: none;
}
.iconbtn:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.08); }

#tabs button:active { opacity: 0.7; }

.title-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 4px;
}
.title-block .title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-block .kw {
  font-size: 12px;
  color: var(--text-54);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.header-spinner {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.today-btn {
  color: var(--primary);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 20px;
}
.today-btn:hover { background: rgba(33, 150, 243, 0.12); }

/* ---------- Day tabs ---------- */

#tabs {
  display: flex;
  border-bottom: 1px solid var(--divider);
}

#tabs button {
  flex: 1;
  padding: 10px 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-54);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}

#tabs button .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
}

#tabs button.is-today { color: var(--primary); font-weight: 800; }
#tabs button.is-today .dot { background: var(--primary); }
#tabs button.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}
#tabs button.active.is-today { color: var(--primary); }

/* ---------- Notice banner ---------- */

#notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 12px 16px;
  background: #1f2b3a;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
#notice span { flex: 1; min-width: 0; }
#notice button {
  color: #64b5f6;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  flex: none;
  white-space: nowrap;
}
#notice button:hover { background: rgba(100, 181, 246, 0.12); }

/* ---------- Schedule list ---------- */

main { overflow: hidden; }

/* ---------- Seamles Pager (Tageswechsel wie PageView in der App) ----------
   Alle 5 Tage liegen nebeneinander im Track; der Track folgt dem Finger 1:1
   und schnappt danach auf die nächste Seite. Jede Seite scrollt vertikal
   eigenständig — die Scroll-Position bleibt beim Seitenwechsel erhalten. */

.pager {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.pager-track {
  display: flex;
  width: 500%;
  height: 100%;
  will-change: transform;
}

.pager.dragging .pager-track { will-change: transform; cursor: grabbing; }

.day-page {
  width: 20%; /* 1/5 des Tracks = exakt eine Viewport-Breite */
  height: 100%;
  flex: none;
  overflow: hidden;
}

.day-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 8px 16px calc(40px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
}

.day-list {
  position: relative;
  display: flex;
  flex-direction: column;
}

.slot-row {
  display: flex;
  gap: 12px;
  padding-bottom: 6px;
}

.slot-time {
  width: 52px;
  flex: none;
  padding-top: 16px;
  font-size: 14px;
  color: var(--text-70);
  font-variant-numeric: tabular-nums;
}

.slot-body { flex: 1; min-width: 0; }

.card {
  background: var(--surface);
  border-radius: var(--card-radius);
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.lesson {
  flex: 1;
  min-width: 0;
  position: relative;
  padding: 14px 14px 14px 20px;
}

.lesson .edge {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 2px;
  background: var(--edge);
}

.lesson .subject {
  font-weight: 800;
  font-size: 17px;
  padding-right: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roomline {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.roomline svg.pin {
  width: 16px;
  height: 16px;
  fill: var(--edge);
  flex: none;
}
.roomline .room {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.roomline .teacher {
  font-size: 14px;
  color: var(--text-54);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: none;
}

.timerange {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-38);
  font-variant-numeric: tabular-nums;
}

.lesson.cancelled .subject {
  text-decoration: line-through;
  color: var(--text-54);
}
.lesson.cancelled .edge { background: var(--red) !important; }

.badge {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 3px 7px;
  border-radius: 999px;
}
.badge.cancelled { color: var(--red); background: rgba(255, 82, 82, 0.14); }
.badge.changed { color: var(--orange); background: rgba(255, 183, 77, 0.14); }

.lesson .notes {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-54);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Banner / special blocks */
.banner {
  background: var(--surface);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.banner svg.ic { color: var(--edge); fill: var(--edge); flex: none; margin-top: 1px; }
.banner .raw { font-weight: 600; font-size: 14px; }
.banner .comment { margin-top: 2px; font-size: 13px; color: var(--text-54); }

/* Break rows */
.break-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  min-height: 0;
}
.break-row .line { flex: 1; height: 1px; background: rgba(255, 255, 255, 0.24); }
.break-row .label {
  font-size: 13px;
  color: var(--text-38);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.break-row.prominent .line { background: rgba(255, 255, 255, 0.3); }
.break-row.prominent .label { color: var(--text-70); font-weight: 700; }

.gap-12 { height: 12px; }


/* „Jetzt“-Linie — ausgerichtet auf die Karten (rechts der Zeitspalte) */
.now-line {
  position: absolute;
  left: 64px;
  right: 0;
  height: 8px;
  pointer-events: none;
  transition: top 0.9s linear;
}
.now-line::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 3px;
  height: 2px;
  border-radius: 1px;
  background: var(--red);
}
.now-line .dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

/* Empty day */
.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-38);
  font-size: 14px;
}

#offline-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 16px 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 183, 77, 0.12);
  border: 1px solid rgba(255, 183, 77, 0.4);
  color: var(--orange);
  font-size: 12px;
  font-weight: 600;
}
#offline-pill svg.ic { width: 16px; height: 16px; }

#demo-banner {
  margin: 8px 16px 0;
  margin-bottom: calc(8px + env(safe-area-inset-bottom));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #3a3113;
  border: 1px solid #5c4d1e;
  color: #ffddb0;
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Error view ---------- */

.error-view {
  max-width: 460px;
  margin: 48px auto;
  padding: 24px;
  background: var(--surface);
  border-radius: 12px;
  text-align: center;
}
.error-view .material { color: var(--primary); }
.error-view p { color: var(--text-70); font-size: 14px; line-height: 1.55; }
.error-view button {
  margin-top: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
}

/* ---------- Setup view ---------- */

#setup {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
#setup .material { color: var(--primary); }
#setup h2 { margin: 14px 0 6px; font-size: 20px; }
#setup .lead { color: var(--text-70); font-size: 14px; line-height: 1.6; margin: 0 0 12px; }

/* Schritt-für-Schritt-Anleitung: ICS-Link aus dem KBW-Portal holen */
#setup ol.manual {
  margin: 0 0 24px;
  padding: 14px 14px 14px 38px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--divider);
  color: var(--text-70);
  font-size: 14px;
  line-height: 1.7;
}
#setup ol.manual li { padding: 2px 0; }
#setup ol.manual li::marker { color: var(--primary); font-weight: 700; }
#setup ol.manual a { color: var(--primary); font-weight: 600; }
#setup ol.manual strong { color: var(--text); }
#setup ol.manual strong.kachel { color: #ffd54f; }

#setup input {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  outline: none;
}
#setup input:focus { box-shadow: 0 0 0 2px var(--primary); }

#setup .save {
  margin-top: 16px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 13px;
  border-radius: 999px;
}
#setup .save:disabled { opacity: 0.5; }
#setup .save.retry {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--text-70);
}
#setup-error {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 82, 82, 0.1);
  border: 1px solid rgba(255, 82, 82, 0.35);
  color: #ff8a80;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
#setup .fineprint { margin-top: 14px; font-size: 12px; color: var(--text-38); text-align: center; }

/* ---------- Drawer / menu ---------- */

#menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
}

#menu {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--surface);
  z-index: 21;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

#menu .menu-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
#menu .menu-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
#menu .menu-title { font-weight: 700; font-size: 18px; }
#menu .menu-date { font-size: 12px; color: var(--text-38); }

#menu .item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  color: var(--text-70);
  font-weight: 500;
  text-align: left;
  width: 100%;
}
#menu .item:hover { background: rgba(255, 255, 255, 0.06); }
#menu .item.active { color: var(--primary); background: rgba(33, 150, 243, 0.12); }
#menu .item .material { flex: none; }

#menu .divider { height: 1px; background: var(--divider); margin: 8px 0; }
#menu .foot { margin-top: auto; padding: 12px 4px; font-size: 12px; color: var(--text-38); }

/* iOS-Install-Modal */
#ios-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 30;
}
#ios-modal {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(420px, 94vw);
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  z-index: 31;
}
#ios-modal h3 { margin: 0 0 12px; font-size: 17px; }
#ios-modal ol { margin: 0; padding-left: 20px; color: var(--text-70); font-size: 14px; line-height: 1.7; }
#ios-modal ol svg.ic { width: 16px; height: 16px; vertical-align: text-bottom; }
#ios-modal p { margin: 12px 0 0; font-size: 12px; color: var(--text-38); line-height: 1.5; }
#ios-modal button {
  margin-top: 14px;
  width: 100%;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 12px;
  border-radius: 999px;
}

/* ---------- Misc ---------- */

.material { font-size: 22px; line-height: 1; }

/* Inline SVG icons (self-contained, no icon font needed) */
svg.ic {
  width: 22px;
  height: 22px;
  fill: currentColor;
  flex: none;
}
svg.ic.big { width: 40px; height: 40px; }
svg.ic.primary { fill: var(--primary); }

.banner .raw { font-weight: 600; font-size: 14px; }
.banner .comment { margin-top: 2px; font-size: 13px; color: var(--text-54); }

#menu .item svg.ic { width: 20px; height: 20px; }

@media (min-width: 720px) {
  .day-scroll > * { max-width: 728px; margin-left: auto; margin-right: auto; }
  #setup { padding-top: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  #splash, .now-line { transition: none; }
  .spinner, #splash .spinner, .header-spinner { animation-duration: 2.5s; }
}
