/* =========================================================
   Graviat Timer — minimalist, typography-driven clock
   ========================================================= */

:root {
  --fg: #f5f5f7;
  --panel-bg: rgba(20, 20, 26, 0.55);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent: #6c8cff;
  --clock-font: "Inter", system-ui, sans-serif;
  --clock-weight: 400;
  --clock-size: 13vw;
  --solid-color: #0e0e12;
  --scrim: 0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #000;
  color: var(--fg);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ===================== STAGE & BACKGROUNDS ===================== */
#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: default;
  user-select: none;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#bg-color {
  background: var(--solid-color);
}

#bg-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#bg-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#bg-scrim {
  background: #000;
  opacity: calc(var(--scrim) / 100);
  transition: opacity 0.3s ease;
}

body[data-bg-mode="image"] #bg-image,
body[data-bg-mode="video"] #bg-video {
  opacity: 1;
}

/* ===================== CLOCK ===================== */
#clock {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  padding: 4vmin;
}

.date {
  font-size: calc(var(--clock-size) * 0.16);
  font-weight: 400;
  letter-spacing: 0.08em;
  opacity: 0.8;
  font-family: var(--clock-font);
}

.time {
  font-family: var(--clock-font);
  font-weight: var(--clock-weight);
  font-size: var(--clock-size);
  line-height: 0.95;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.colon {
  opacity: 0.7;
  animation: blink 2s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.ampm {
  font-size: 0.28em;
  font-weight: 600;
  margin-left: 0.3em;
  opacity: 0.7;
  align-self: center;
  letter-spacing: 0.05em;
}

/* hide helpers */
body[data-hide-seconds="true"] #seconds-wrap {
  display: none;
}
body[data-hide-date="true"] .date {
  display: none;
}
body[data-hide-progress="true"] .seconds-progress {
  display: none;
}
body[data-hide-watermark="true"] #watermark {
  display: none;
}

.seconds-progress {
  width: min(38vw, 0.62em * 10);
  width: clamp(160px, 26vw, 520px);
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin-top: 0.2em;
}

.seconds-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
}

.custom-text {
  font-family: var(--clock-font);
  font-size: calc(var(--clock-size) * 0.13);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.75;
  min-height: 1em;
}
.custom-text:empty {
  display: none;
}

/* ===================== WATERMARK & HINT ===================== */
.watermark {
  position: fixed;
  bottom: 18px;
  right: 22px;
  z-index: 3;
  font-size: 14px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.35;
  pointer-events: none;
  font-weight: 600;
}

.hint {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 12px;
  letter-spacing: 0.1em;
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.hint.is-faded {
  opacity: 0;
}

/* ===================== IMMERSIVE MODE ===================== */
/* When presenting (fullscreen), all chrome disappears. */
body.is-immersive .settings-toggle,
body.is-immersive .watermark,
body.is-immersive .hint {
  opacity: 0;
  pointer-events: none;
}

/* ===================== SETTINGS TRIGGER ===================== */
.settings-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(20, 20, 26, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.settings-toggle:hover {
  opacity: 1;
  transform: rotate(45deg);
}

/* ===================== GLASS PANEL ===================== */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  height: 100%;
  width: 360px;
  max-width: 88vw;
  background: var(--panel-bg);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-left: 1px solid var(--panel-border);
  transform: translateX(105%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  color: var(--fg);
}
.panel.is-open {
  transform: translateX(0);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--panel-border);
}
.panel__title {
  font-size: 18px;
  font-weight: 200;
  letter-spacing: 0.04em;
}
.panel__title span {
  font-weight: 700;
}
.panel__close {
  background: none;
  border: none;
  color: var(--fg);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
}
.panel__close:hover {
  opacity: 1;
}

.panel__body {
  overflow-y: auto;
  padding: 8px 22px 28px;
  flex: 1;
}
.panel__body::-webkit-scrollbar {
  width: 8px;
}
.panel__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

/* ===================== GROUPS & ROWS ===================== */
.group {
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.group:last-of-type {
  border-bottom: none;
}
.group__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.5;
  margin-bottom: 12px;
  font-weight: 600;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
}
.row > label {
  font-size: 14px;
  opacity: 0.9;
}

/* ===================== CONTROLS ===================== */
.segmented {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: none;
  background: none;
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
  transition: background 0.2s, opacity 0.2s;
}
.segmented button.is-active {
  background: var(--accent);
  opacity: 1;
}

/* toggle switch */
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.2);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch:checked {
  background: var(--accent);
}
.switch:checked::after {
  transform: translateX(18px);
}

.select,
.text-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: var(--fg);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  max-width: 58%;
}
.text-input {
  width: 58%;
}
.select option {
  color: #111;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 56%;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 30px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  padding: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

/* swatches & gallery */
.bg-pane {
  padding-top: 6px;
}
.bg-pane.is-hidden {
  display: none;
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
}
.swatch.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.thumb {
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border: 2px solid transparent;
}
.thumb.is-active {
  border-color: var(--accent);
}

.file-btn {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 10px;
}
.file-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.panel__foot {
  padding-top: 18px;
}
.ghost-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--fg);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
}
.ghost-btn:hover {
  opacity: 1;
  border-color: var(--accent);
}

@media (max-width: 480px) {
  :root {
    --clock-size: 22vw;
  }
}
