:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #1e1e1e;
  --text: #eee;
  --eventText: #111;
  --muted: #888;
  --border: #555;
  --available: #2a2a2a;
  --reservation: #0352ad;
  --checkout: #4caf50;
  --booked: #444;
  --late-text: #FAA;
  --defaultSize: 12px;
  --stickyOffset: 43px; /* note to self: is dynamically */
}

html, body {
  forced-color-adjust: none;
  touch-action: manipulation;
  margin: 0;
  padding: 0;
}

html.cursor-hidden {
  cursor: none;
}

body {
  margin: 1px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,"Noto Sans", "Liberation Sans", sans-serif;
  font-size: var(--defaultSize);
  color: var(--text);
  background-color: var(--bg);
  background-size: cover;
}

body.cursor-hidden {
  cursor: none;
}

#calendarHeader {
  text-align: center;
  margin: 10px 0 5px;
}

.calendarHeader {
  text-align: center;
  margin: 10px 0 5px;
}

#calendarVersion {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  margin: 0 0 20px;
}

#calendarNav {
  text-align: center;
  margin: 10px 0;
}

#calendarNav button,
.calendarNavDup button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  margin: 20px 20px 0 0;
  cursor: pointer;
  padding: 12px 12px;
  border-radius: 16px;
}

#calendarNav button:hover,
.calendarNavDup button:hover {
  filter: brightness(1.2);
}

#calendarNav input[type="date"],
.calendarNavDup input[type="date"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 16px;
  margin: 0 20px 0 0;
  cursor: pointer;

  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

#calendarNav input[type="date"]:hover,
#calendarNav input[type="date"]:focus,
.calendarNavDup input[type="date"]:hover,
.calendarNavDup input[type="date"]:focus {
  filter: brightness(1.2);
  outline: none;
}

#calendarNav input[type="date"]::-webkit-calendar-picker-indicator,
.calendarNavDup input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

#calendarNav button.fontSizeBtn {
  padding: 8px 12px;
  min-width: 32px;
}

.dayNavGroup {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 12px;
}

:root[data-nav-mode="single"] #calendarNav {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
:root[data-nav-mode="single"] #calendarNav span,
:root[data-nav-mode="single"] #calendarNav input,
:root[data-nav-mode="single"] #calendarNav button,
:root[data-nav-mode="single"] #calendarNav .dayNavGroup {
  margin: 0;
}

.calendarTable + .calendarTable {
  margin-top: 48px !important;
}
.calendarTable tr:last-child > td,
tr:last-child > th {
  border-bottom: 0;
}
.calendarTable {
  width: 100%;
  table-layout: fixed;
  border-spacing: 1;
}
.calendarTable th,
.calendarTable td {
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  font-weight: bold;
  font-family: inherit;
  border: 0;
  padding: 0;
  overflow: hidden; /* ensure scaled text doesn't expand cell size */
}
.calendarTable th {
  color: #ffffff;
  /* Higher-contrast header gradient for TV readability */
  background: linear-gradient(180deg, #032f4a 0%, #014a63 100%);
  padding: 5px 0;
  height: 2.6em;
  line-height: 1.2em;
  white-space: normal;
  text-align: center;
  vertical-align: middle;
  text-shadow: 0 2px 6px rgba(0,0,0,0.75);
  border-bottom: 1px solid rgba(0,0,0,0.45);
}
.calendarTable td.timeCell {
  background-color: var(--panel);
}
.calendarTable td.timeCell.currentTimeCell {
  color: #fff;
  text-shadow: 0 0 8px #FA0, 0 0 16px #FA0;
  animation: glowFade 3s ease-in-out infinite;
}

.calendarTable td.cell.available { background-color: var(--available); }
.calendarTable td.unavailable,
.calendarTable td.unavailableLarge {
  background-color: #222;
  color: #bbb;
  font-style: italic;
  text-align: center;
}
.calendarTable td.unavailableLarge { font-size: large; }
.calendarTable td.cell.reservation {
  color: var(--eventText);
  text-shadow: 0 -1px 1px rgba(0,0,0,0.4),
               0 1px 1px rgba(255,255,255,0.5);
  border: none;
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.9),
              inset 0 1px 0 rgba(255,255,255,0.4);
  border-radius: 6px;
  background: linear-gradient(to bottom,
    #70b6f2 0%, #54a3ee 50%, #3690f0 50%, #1a62db 100%);
}
.calendarTable td.cell.checkout {
  color: var(--eventText);
  text-shadow: 0 -1px 1px rgba(0,0,0,0.4),
               0 1px 1px rgba(255,255,255,0.5);
  border: none;
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.9),
              inset 0 1px 0 rgba(255,255,255,0.4);
  border-radius: 6px;
  background: linear-gradient(to bottom,
    #daffbc 0%, #7fd33a 50%, #69b926 52%, #b7ff7d 100%);
}

.calendarTable td.cell.short-event {
  font-size: 0.8em;
}
.calendarTable td.cell.booked {
  background-color: var(--booked);
  color: var(--text);
}
.calendarTable td.cell.late {
  border: none;
  border-radius:6px;
  background: linear-gradient(to bottom,
    #fd8f9b 0%, #f55 50%, #f60000 50%, #ffa7b0 100%);
}

.calendarClosedMessage {
  background: #222;
  color: #bbb;
  font-style: italic;
  text-align: center;
  padding: 2em;
  font-size: 1.5em;
  border-radius: 6px;
}

.calendarTable th:first-child,
.calendarTable td.timeCell {
  width: 100px;
  min-width: 80px;
  max-width: 120px;
  white-space: nowrap;
}

.calendarTable td.loading {
  color: var(--text);
  text-align: center;
  padding: 40px 0;
  font-weight: bold;
  font-size: 2em;
  letter-spacing: 2px;
}

/* === Calendar Loading Progress Bar === */
#progressContainer {
  width: 100%;
  height: 20px;
  margin: 0; /* no vertical margin, since it's sticky below nav */
  border-radius: 4px;
  overflow: hidden;
  box-sizing: border-box;
  background: transparent;
  transition: background .3s, opacity .5s;
  opacity: 0;

  /* sticky placement to stay under nav/header */
  position: sticky;
  top: var(--stickyOffset); /* dynamic offset set by JS */
  z-index: 900;             /* above tables but below header */
}

#progressContainer.loading {
  background: #eee; /* visible bar background */
  opacity: 1;
}

#progressBar {
  height: 100%;
  width: 0%; /* updated dynamically from JS */
  background: linear-gradient(to right, #FA0, #4caf50);
  transition: width .3s linear;
  box-shadow: 0 0 5px rgba(0,0,0,.2);
}

#progressContainer.loading #progressBar {
  display: block;
}

#progressText {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.85em;
  color: #000;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
}

/* neon effects */
.orangeGlow {
  color: #fff;
  text-shadow: 0 0 8px #FA0, 0 0 16px #FA0;
  animation: glowFade 3s ease-in-out infinite;
}

@keyframes glowFade {
  0%, 100% {
    text-shadow: 0 0 6px #FA0, 0 0 12px #FA0;
  }
  50% {
    text-shadow: 0 0 12px #FA0, 0 0 24px #FA0;
  }
}

/* glossy buttons */
.blueGloss {
  text-shadow: 0 -1px 1px rgba(0,0,0,0.4),
               0 1px 1px rgba(255,255,255,0.5);
  border: none;
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.9),
              inset 0 1px 0 rgba(255,255,255,0.4);
  border-radius: 6px;
  background: linear-gradient(
    to bottom,
    #70b6f2 0%,
    #54a3ee 50%,
    #3690f0 50%,
    #1a62db 100%
  );
}

.greenGloss {
  text-shadow: 0 -1px 1px rgba(0,0,0,0.4),
               0 1px 1px rgba(255,255,255,0.5);
  border: none;
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.9),
              inset 0 1px 0 rgba(255,255,255,0.4);
  border-radius: 6px;
  background: linear-gradient(
    to bottom,
    #daffbc 0%,
    #7fd33a 50%,
    #69b926 52%,
    #b7ff7d 100%
  );
}

.tealGloss {
  border: none;
  border-radius: 6px;
  background: linear-gradient(
    to bottom,
    #c2d9df 0%,
    #69a7a4 48%,
    #006662 52%,
    #03b7ac 100%
  );
}

.greyGloss {
  background: linear-gradient(to bottom, transparent, #333);
  color: #666;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
.loader {
  border: 4px solid #555;
  border-top: 4px solid #FA0;
  border-radius: 50%;
  width: 30px; height: 30px;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

/* sticky header wrapper */
#stickyTop {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1000;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Layout container (non-TO = block, TO = flex) */
#mainLayout {
  display: block;
}
#techViewport {
  display: none;
}

/* Tech Officer (tech=TO) mode overrides */
html[data-tech="TO"], 
html[data-tech="TO"] body {
  height: 99%;
  margin: 0;
  padding: 0;
}

html[data-tech="TO"] #mainLayout {
  height: calc(100% - var(--stickyOffset));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html[data-tech="TO"] #calendarContainer {
  flex: 0 0 auto;
  min-height: 0;
}

html[data-tech="TO"] #techViewport {
  display: block;
  flex: 1 1 auto;
  min-height: 120px;
  overflow: hidden;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

html[data-tech="TO"] #techViewport webview {
  width: 100%;
  height: 100%;
  border: none;
}

#reservationLink {
  text-align: center;
  margin: 20px 0;
}

#reservationLink a {
  color: #4cafef;
  font-size: 1.2em;
  font-weight: bold;
}

/* Version label in top-right bar */
#versionLabel {
  color: #999;
  font-size: 0.9em;
  vertical-align: middle;
}


#authSection {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 80vh;
  text-align: center;
}

#authSection button {
  background: #4285F4;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-size: 1.1em;
  cursor: pointer;
}
#authSection button:hover {
  filter: brightness(1.1);
}

#qrBlock {
  text-align: center;
  margin: 12px 0;
}

#qrBlock .qrRow {
  display: inline-flex;              /* keep text + image side-by-side */
  align-items: center;               /* vertical alignment */
  gap: 12px;                         /* space between text and image */
  background: var(--panel);          /* subtle background panel */
  padding: 6px 12px;
  border-radius: 8px;
}

#qrBlock span {
  font-size: 2em;
  white-space: nowrap;
}

#qrBlock img {
  height: 100px;                     /* fixed, smaller height */
  width: auto;
  border: 2px solid var(--border);   /* neat border around QR */
  border-radius: 6px;
  background: #fff;
}

/* When QR is visible we make text wider only (not the table layout). */
/* Better: scale text only (not table borders/layout) when QR visible. */
html.qr-visible .calendarTable .cellInner,
html.qr-visible .calendarTable th .cellInner {
  display: block;
  width: 100%;
  /* Preserve text wrapping while making text appear wider horizontally. */
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;

  /* Slightly stronger horizontal expansion while preserving wrapping: */
  letter-spacing: 0.08em;    /* a bit more spacing between letters */
  word-spacing: 0.05em;      /* slightly larger spacing between words */
  font-stretch: 125%;        /* 125% horizontal glyph stretch where supported */

  /* Improve rendering on TVs */
  text-rendering: optimizeLegibility;
}