:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: #0f172a;
  --text: #f8fafc;
  --muted: #94a3b8;
  --blue: #38bdf8;
  --red: #f87171;
  --green: #4ade80;
  --line: rgba(255, 255, 255, 0.07);
  --header-height: 80px;
  --header-height: clamp(68px, 7.4vh, 80px);
  --sidebar-width: 142px;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #020617;
  background: var(--bg);
  color: #f8fafc;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
}

body.cursor-hidden,
body.cursor-hidden * {
  cursor: none !important;
}

.infotv-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#header {
  width: 100%;
  height: 80px;
  height: var(--header-height);
  padding: 0 60px;
  padding: 0 clamp(24px, 3.1vw, 60px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(2, 6, 23, 0.9);
}

.title {
  flex: 0 0 auto;
  color: #f8fafc;
  color: var(--text);
  font-size: 1.5rem;
  font-size: clamp(1rem, 1.25vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 3px;
  letter-spacing: clamp(1.5px, 0.16vw, 3px);
  white-space: nowrap;
}

#ticker-container {
  min-width: 0;
  height: 100%;
  margin: 0 40px;
  margin: 0 clamp(20px, 2.1vw, 40px);
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
}

#ticker-container[hidden] {
  display: none;
}

.ticker-text {
  display: inline-block;
  padding-left: 100%;
  color: #f87171;
  color: var(--red);
  font-size: 1.6rem;
  font-size: clamp(1rem, 1.35vw, 1.6rem);
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  animation: ticker 32s linear infinite;
  animation: ticker var(--ticker-duration, 32s) linear infinite;
}

@keyframes ticker {
  to {
    transform: translateX(-100%);
  }
}

#header-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

#qr-actions {
  margin-right: 25px;
  margin-right: clamp(12px, 1.3vw, 25px);
  display: flex;
  align-items: center;
}

.qr-container {
  margin-left: 8px;
  margin-left: clamp(5px, 0.42vw, 8px);
  padding: 5px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.qr-container:first-child {
  margin-left: 0;
}

#calendar-qr-container {
  background: rgba(56, 189, 248, 0.1);
}

.qr-text {
  margin-right: 10px;
  color: #94a3b8;
  color: var(--muted);
  font-size: 0.65rem;
  font-size: clamp(0.53rem, 0.55vw, 0.65rem);
  line-height: 1.2;
  letter-spacing: 1px;
  text-align: right;
  text-transform: uppercase;
}

.qr-code {
  width: 50px;
  width: clamp(42px, 2.6vw, 50px);
  height: 50px;
  height: clamp(42px, 2.6vw, 50px);
  border-radius: 4px;
  background: #fff;
}

/* Säilytetään vanhat tunnisteet myös vanhoja välimuistiversioita varten. */
#qr-container {
  flex: 0 0 auto;
}

#calendar-qr-container {
  flex: 0 0 auto;
}

#clock {
  color: #94a3b8;
  color: var(--muted);
  font-size: 1.5rem;
  font-size: clamp(1rem, 1.25vw, 1.5rem);
  font-weight: 300;
  letter-spacing: 1px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#main-wrapper {
  width: 100%;
  min-height: 0;
  display: -webkit-flex;
  display: flex;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
}

#sidebar {
  width: 142px;
  min-width: 142px;
  max-width: 142px;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  height: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-flex: 0 0 142px;
  flex: 0 0 142px;
  -webkit-flex-basis: var(--sidebar-width);
  flex-basis: var(--sidebar-width);
  -webkit-flex-direction: column;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(15, 23, 42, 0.48);
  box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
}

#sidebar-calendar {
  width: 100%;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  padding: 10px 8px;
  padding: clamp(8px, 1.1vh, 12px) 8px;
  flex: 1 1 auto;
  overflow: hidden;
}

#sidebar-hsl {
  width: 100%;
  height: 280px;
  height: clamp(244px, 25.9vh, 280px);
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #020617;
  background: var(--bg);
}

.sidebar-loading,
.sidebar-empty {
  padding-top: 18px;
  color: #64748b;
  font-size: 0.68rem;
  line-height: 1.4;
  text-align: center;
}

.sidebar-date-heading {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 8px 0 5px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  color: var(--blue);
  font-size: 0.68rem;
  font-size: clamp(0.58rem, 0.58vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.sidebar-date-heading:first-child {
  margin-top: 0;
}

.sidebar-event {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 6px;
  padding-left: 5px;
  border-left: 2px solid #38bdf8;
  border-left: 2px solid var(--blue);
  overflow: hidden;
}

.sidebar-event-time {
  color: #f8fafc;
  color: var(--text);
  font-size: 0.64rem;
  font-size: clamp(0.56rem, 0.55vw, 0.66rem);
  font-weight: 600;
}

.sidebar-event-title {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 1px;
  color: #cbd5e1;
  font-size: 0.56rem;
  font-size: clamp(0.49rem, 0.48vw, 0.57rem);
  font-weight: 300;
  line-height: 1.18;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.sidebar-event-location {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 1px;
  color: #64748b;
  font-size: 0.44rem;
  line-height: 1.1;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

#hsl-departures {
  min-height: 0;
  padding: 3px 6px 5px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
}

.hsl-group {
  min-height: 0;
  flex: 0 0 auto;
}

.hsl-group + .hsl-group {
  margin-top: 2px;
}

.hsl-group-title {
  min-height: 9px;
  padding-bottom: 1px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.18);
  color: #94a3b8;
  font-size: 0.43rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.hsl-towards-city .hsl-group-title {
  color: #f8fafc;
}

.hsl-away-from-city .hsl-group-title {
  color: #94a3b8;
}

.hsl-group-empty {
  padding: 3px 0 2px;
  color: #64748b;
  font-size: 0.52rem;
}

.hsl-row {
  height: 17px;
  min-height: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.hsl-row:last-child {
  border-bottom: 0;
}

.hsl-line {
  min-width: 23px;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-size: clamp(0.68rem, 0.7vw, 0.82rem);
  font-weight: 700;
}

.hsl-dest {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: #e2e8f0;
  font-size: 0.58rem;
  font-size: clamp(0.5rem, 0.49vw, 0.58rem);
  font-weight: 400;
  line-height: 1.08;
}

.hsl-headsign,
.hsl-stop {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hsl-stop {
  margin-top: 0;
  color: #64748b;
  font-size: 0.39rem;
  line-height: 1;
  letter-spacing: 0.1px;
}

.hsl-time {
  width: 19px;
  flex: 0 0 auto;
  color: #f8fafc;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
  font-size: clamp(0.72rem, 0.76vw, 0.9rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hsl-time.realtime {
  color: #4ade80;
  color: var(--green);
}

#slides-container {
  width: calc(100% - 142px);
  width: calc(100% - var(--sidebar-width));
  height: 100%;
  min-width: 0;
  min-height: 0;
  position: relative;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow: hidden;
  background: #000;
}

.view-slide {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
  background: radial-gradient(circle at center, #0f172a 0%, var(--bg) 100%);
  transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}

.view-slide.active {
  z-index: 10;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.content {
  width: 88%;
  max-width: 1700px;
  max-height: 95%;
  margin: 0 auto;
  padding: 60px 90px;
  padding: clamp(34px, 5.55vh, 60px) clamp(50px, 4.7vw, 90px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 24px;
  background: rgba(30, 41, 59, 0.3);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.menu-grid {
  display: flex;
  justify-content: space-between;
}

.day-col {
  margin: 0 clamp(22px, 2.1vw, 40px);
  flex: 1 1 0;
}

.day-col:first-child {
  margin-left: 0;
}

.day-col:last-child {
  margin-right: 0;
}

.day-col h2 {
  margin-bottom: clamp(18px, 2.7vh, 29px);
  color: #38bdf8;
  color: var(--blue);
  font-size: clamp(0.9rem, 0.92vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.course-item {
  margin-bottom: clamp(17px, 2.3vh, 25px);
}

.course-type {
  margin-bottom: 4px;
  color: #94a3b8;
  color: var(--muted);
  font-size: clamp(0.66rem, 0.66vw, 0.78rem);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.course-main {
  color: #f8fafc;
  color: var(--text);
  font-size: clamp(1.2rem, 1.4vw, 1.65rem);
  font-weight: 400;
  line-height: 1.25;
}

.empty-menu {
  color: #94a3b8;
  color: var(--muted);
  font-size: clamp(1rem, 1.16vw, 1.4rem);
  font-style: italic;
  font-weight: 300;
}

.cal-day-group {
  margin-bottom: clamp(22px, 3.7vh, 40px);
}

.cal-date-header {
  display: inline-block;
  margin-bottom: clamp(12px, 1.85vh, 20px);
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  color: var(--blue);
  font-size: clamp(0.86rem, 0.88vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.cal-event-row {
  padding-bottom: clamp(9px, 1.1vh, 12px);
  margin-bottom: clamp(9px, 1.1vh, 12px);
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.cal-time {
  width: clamp(100px, 6.6vw, 126px);
  flex: 0 0 auto;
  color: #38bdf8;
  color: var(--blue);
  font-size: clamp(0.95rem, 1.16vw, 1.4rem);
  font-weight: 500;
}

.cal-title {
  color: #cbd5e1;
  font-size: clamp(0.94rem, 1.02vw, 1.22rem);
  font-weight: 300;
  line-height: 1.35;
}

.cal-location {
  color: #64748b;
  font-size: 0.8em;
}

.bulletin-container {
  width: 100%;
  height: 100%;
  max-width: 90%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.bulletin-title {
  margin-bottom: clamp(20px, 3vh, 32px);
  padding-bottom: clamp(11px, 1.5vh, 16px);
  border-bottom: 3px solid rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  color: var(--blue);
  font-size: 2.3rem;
  font-size: clamp(1.5rem, 2vw, 2.3rem);
  font-weight: 600;
  letter-spacing: 1px;
}

.bulletin-items {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
}

.bulletin-item {
  position: relative;
  margin-bottom: clamp(14px, 1.9vh, 21px);
  padding-left: clamp(28px, 2vw, 38px);
  color: #f8fafc;
  color: var(--text);
  font-size: clamp(1.3rem, 1.65vw, 2rem);
  font-weight: 400;
  line-height: 1.25;
}

.bulletin-item::before {
  content: "▶";
  position: absolute;
  left: 0;
  top: 0.08em;
  color: #38bdf8;
  color: var(--blue);
}

.bulletin-read-more {
  margin-top: clamp(19px, 3vh, 33px);
  color: #f87171;
  color: var(--red);
  font-size: clamp(0.85rem, 1vw, 1.2rem);
  font-weight: 500;
  letter-spacing: 1px;
  text-align: right;
}

.iframe-wrapper,
.media-frame {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  background: #000;
}

img.media-frame,
video.media-frame {
  display: block;
  object-fit: contain;
}

.media-image {
  width: 100%;
  height: 100%;
  background-color: #000;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.media-fallback {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  z-index: 20;
  padding: 10px;
  color: #94a3b8;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.84);
  font-size: 0.75rem;
  text-align: center;
}

.loading-slide {
  gap: 20px;
  color: #94a3b8;
  color: var(--muted);
  font-size: 1rem;
}

.loading-title {
  color: #f8fafc;
  color: var(--text);
  font-size: clamp(1.8rem, 2.6vw, 3.1rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.loading-pulse {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(56, 189, 248, 0.18);
  border-top-color: #38bdf8;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#pagination {
  position: absolute;
  bottom: 15px;
  left: calc(142px + (100vw - 142px) / 2);
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  z-index: 1000;
  padding: 6px 16px;
  display: flex;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.01);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
}

#pagination[hidden] {
  display: none;
}

.dot {
  width: 5px;
  height: 5px;
  margin: 0 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: 0.4s ease;
}

.dot.active {
  background: rgba(56, 189, 248, 0.6);
  transform: scale(1.4);
}

#source-warning {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 1100;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f87171;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.12);
}

#source-warning[hidden] {
  display: none;
}

/* Androidin vanhat WebView-versiot eivät tunne clamp()-funktiota. */
@supports not (font-size: clamp(1rem, 2vw, 2rem)) {
  .sidebar-date-heading { font-size: 0.68rem; }
  .sidebar-event { margin-bottom: 6px; }
  .sidebar-event-time { font-size: 0.64rem; }
  .sidebar-event-title { font-size: 0.56rem; }
  .hsl-line { font-size: 0.82rem; }
  .hsl-dest { font-size: 0.58rem; }
  .hsl-time { font-size: 0.84rem; }
  .day-col { margin-right: 40px; margin-left: 40px; }
  .day-col h2 { margin-bottom: 29px; font-size: 1.1rem; }
  .course-item { margin-bottom: 25px; }
  .course-type { font-size: 0.78rem; }
  .course-main { font-size: 1.65rem; }
  .empty-menu { font-size: 1.4rem; }
  .cal-day-group { margin-bottom: 40px; }
  .cal-date-header { margin-bottom: 20px; font-size: 1.05rem; }
  .cal-event-row { margin-bottom: 12px; padding-bottom: 12px; }
  .cal-time { width: 126px; font-size: 1.4rem; }
  .cal-title { font-size: 1.22rem; }
  .bulletin-title { margin-bottom: 32px; padding-bottom: 16px; font-size: 2.3rem; }
  .bulletin-item { margin-bottom: 21px; padding-left: 38px; font-size: 2rem; }
  .bulletin-read-more { margin-top: 33px; font-size: 1.2rem; }
  .loading-title { font-size: 2.7rem; }
}

@media (max-width: 980px) {
  .qr-text {
    display: none;
  }

  #header {
    padding-right: 20px;
    padding-left: 20px;
    padding-inline: 20px;
  }

  .content {
    width: 92%;
    padding-right: 38px;
    padding-left: 38px;
    padding-inline: 38px;
  }
}

@media (max-width: 720px) {
  :root {
    --sidebar-width: 112px;
  }

  #sidebar {
    width: 112px;
    min-width: 112px;
    max-width: 112px;
    -webkit-flex: 0 0 112px;
    flex: 0 0 112px;
  }

  #slides-container {
    width: calc(100% - 112px);
  }

  #pagination {
    left: calc(112px + (100vw - 112px) / 2);
  }

  .title {
    font-size: 0.83rem;
  }

  #clock {
    font-size: 0.75rem;
  }

  #qr-actions {
    display: none;
  }
}

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