/* ------------------------------------------------------------------
   Lumy clock — single-widget live preview
   ------------------------------------------------------------------ */

:root {
  --bg-page: #f6f6f4;
  --bg-photo-fallback: #f1efeb;
  --ink: #16140f;
  --ink-2: #4a463d;
  --ink-3: #8a8579;
  --line: rgba(20, 18, 12, 0.10);
  --line-soft: rgba(20, 18, 12, 0.06);
  --divider: rgba(20, 18, 12, 0.10);
  --accent: #1a8f5a;
  --accent-soft: rgba(26, 143, 90, 0.14);
  --warm: #c47a3a;
  --warm-soft: rgba(196, 122, 58, 0.14);

  --radius-widget: 28px;
  --radius-pill: 999px;
  --radius-panel: 20px;

  --shadow-stage: 0 1px 0 rgba(20,18,12,0.04), 0 30px 70px -40px rgba(20,18,12,0.28);
  --shadow-button: 0 4px 14px -6px rgba(20,18,12,0.18), 0 1px 2px rgba(20,18,12,0.04);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;

  /* picker geometry */
  --wheel-item: 38px;
  --wheel-visible: 3;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100svh;
}

/* ------------------------------------------------------------------
   Page chrome
   ------------------------------------------------------------------ */

.page {
  padding: 0;
  margin: 0;
}

/* ------------------------------------------------------------------
   The widget
   ------------------------------------------------------------------ */

.widget {
  position: relative;
  width: 100%;
  background: var(--bg-photo-fallback);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.widget__clock {
  position: relative;
  width: 100%;
  height: 100svh;
  background: var(--bg-photo-fallback);
  cursor: default;
  touch-action: pan-y;
  -webkit-user-drag: none;
  overflow: hidden;
}
.widget__clock .clock-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.widget__clock .clock-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* SVG overlay LED paths — transparent by default; JS sets fill */
#clock-svg g[id^="Line"] path,
#clock-svg g[id^="Num"] path {
  fill: rgba(255, 255, 255, 0);
  transition: fill 60ms linear;
}

/* ============ TIME PICKER (overlay top — text + thin lines) ============ */

.picker {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: var(--ink);
  pointer-events: none; /* click-through on gaps; wheels/button restore via pointer-events: auto */
}

.picker__caption {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-2);
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}
.picker__caption--left  { grid-column: 1; justify-self: end;   text-align: center; padding-right: 14px; }
.picker__caption--right { grid-column: 3; grid-row: 1; justify-self: start; text-align: center; padding-left: 14px; }

.picker__wheels {
  grid-column: 2;
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: calc(var(--wheel-item) * var(--wheel-visible));
  isolation: isolate;
}
/* thin black band lines marking the active row — top and bottom of center cell */
.picker__wheels::before,
.picker__wheels::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
  z-index: 2;
  pointer-events: none;
}
.picker__wheels::before { top: calc(50% - var(--wheel-item) / 2); }
.picker__wheels::after  { top: calc(50% + var(--wheel-item) / 2); }

.wheel {
  position: relative;
  height: 100%;
  width: 52px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior: contain;
  z-index: 1;
  cursor: grab;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 28%, #000 72%, transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 28%, #000 72%, transparent 100%);
}
.wheel.is-dragging { cursor: grabbing; }
.wheel::-webkit-scrollbar { display: none; }

.wheel__item {
  height: var(--wheel-item);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: currentColor;
  scroll-snap-align: center;
  transition: opacity 80ms linear, transform 80ms linear;
  will-change: opacity, transform;
  user-select: none;
  pointer-events: none;
}
.wheel__pad {
  height: calc((var(--wheel-visible) - 1) * var(--wheel-item) / 2);
  scroll-snap-align: none;
}
.wheel__sep {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: currentColor;
  padding: 0 3px;
  z-index: 1;
  user-select: none;
  align-self: center;
}

.picker.no-seconds .wheel--s,
.picker.no-seconds .wheel__sep--s { display: none; }

/* "Live" button — replaces the right caption when override */
.picker__back {
  grid-column: 3;
  grid-row: 1;
  justify-self: start;
  margin-left: 14px;
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(196, 122, 58, 0.35);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--warm);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease;
  white-space: nowrap;
}
.picker__back:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
}
.picker__back-icon {
  display: inline-block;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  background-color: var(--warm);
  -webkit-mask: url('assets/undo.svg') center / contain no-repeat;
  mask: url('assets/undo.svg') center / contain no-repeat;
}

/* swap caption <-> back button on override */
.picker.is-override .picker__caption--right { display: none; }
.picker.is-override .picker__back            { display: inline-flex; }

/* ============ MODE SELECTOR (one bar, internal dividers) ============ */

.modes {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 200px;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-button);
  overflow: hidden;
}

/* prev / next combined segments — arrow + Switch to + name */
.mode-side {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
  min-width: 0;
  white-space: nowrap;
}
.mode-side svg { width: 14px; height: 14px; flex-shrink: 0; }
.mode-side__hint { display: none; }
.mode-side__name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.mode-side:hover { background: rgba(255, 255, 255, 0.5); color: var(--ink); }
.mode-side:active { background: rgba(255, 255, 255, 0.3); }

.mode-side--prev { justify-content: center; }
.mode-side--next { justify-content: center; }

/* active mode (center segment) — clipping container, borders stay fixed */
.mode-active {
  border-left: 1px solid var(--divider);
  border-right: 1px solid var(--divider);
  overflow: hidden;
  min-width: 0;
  display: flex;
  align-items: center;
}
/* slideable inner content */
.mode-active__inner {
  width: 100%;
  flex-shrink: 0;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  will-change: translate;
}
.mode-active__row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
}
.mode-active__row .mode-active__name {
  grid-column: 2;
}
.mode-active__row .mode-info-btn {
  grid-column: 3;
  justify-self: start;
  padding-left: 4px;
}
.mode-active__name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.15;
}
.mode-info-btn {
  appearance: none;
  border: none;
  background: none;
  padding: 2px;
  cursor: pointer;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 160ms ease;
}
.mode-info-btn:hover,
.mode-info-btn.is-active { color: var(--ink); }
.mode-active__hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-3);
}
.mode-info-popup {
  position: fixed;
  background: rgba(22, 20, 15, 0.9);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 16px;
  z-index: 20;
  pointer-events: none;
}
.mode-info-popup[hidden] { display: none; }
#mode-info-popup-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #fafaf6;
  text-align: center;
}
.mode-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 6px;
}
.mode-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(20,18,12,0.22);
  transition: background 180ms ease, width 180ms ease;
  cursor: pointer;
}
.mode-dots span.is-on {
  background: var(--ink);
  width: 18px;
  border-radius: 3px;
}


/* ------------------------------------------------------------------
   RESPONSIVE: image crops, doesn't shrink. UI scales down.
   ------------------------------------------------------------------ */

@media (max-width: 760px) {
  .picker { top: 14px; }
  .wheel { width: 46px; }
  .wheel__item, .wheel__sep { font-size: 18px; }

  .modes {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: 96px 1fr 96px;
  }
  .mode-side {
    padding: 10px 12px;
    font-size: 12px;
    gap: 4px;
  }
  .mode-active__inner { padding: 10px 12px; }
  .mode-active__name { font-size: 14px; }
  .mode-active__hint { font-size: 10.5px; line-height: 1.3; }
}

/* Very narrow: hide the prev/next NAMES too, keep only arrows */
@media (max-width: 420px) {
  .mode-side__name { display: none; }
  .mode-side { padding: 12px; }
  .modes { grid-template-columns: 52px 1fr 52px; }
}

/* ------------------------------------------------------------------
   Tweaks panel
   ------------------------------------------------------------------ */
.tweaks-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 280px;
  background: rgba(22, 20, 15, 0.92);
  color: #fafaf6;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 14px 16px 16px;
  font-size: 13px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.4);
  z-index: 999;
  font-family: var(--font-sans);
}
.tweaks-panel[hidden] { display: none; }
.tweaks-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(255,255,255,0.55); font-weight: 500;
}
.tweaks-panel__close {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 4px; opacity: 0.7;
}
.tweaks-panel__close:hover { opacity: 1; }
.tweak-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.tweak-row:last-child { margin-bottom: 0; }
.tweak-row__label { font-size: 12px; color: rgba(255,255,255,0.6); font-weight: 500; }
.tweak-seg { display: flex; background: rgba(255,255,255,0.06); border-radius: 8px; padding: 3px; gap: 2px; }
.tweak-seg button {
  appearance: none; border: none; background: transparent;
  color: rgba(255,255,255,0.7);
  font: inherit; font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: 6px;
  cursor: pointer; flex: 1;
  transition: all 180ms ease;
}
.tweak-seg button.is-active { background: rgba(255,255,255,0.16); color: #fff; }
.tweak-seg button:hover:not(.is-active) { color: #fff; background: rgba(255,255,255,0.04); }

/* dark variant */
body.theme-dark {
  --bg-page: #0d0c0a;
  --ink: #fafaf6;
  --ink-2: #c8c4b8;
  --ink-3: #8a8579;
  --line: rgba(255,255,255,0.10);
  --line-soft: rgba(255,255,255,0.06);
  --divider: rgba(255,255,255,0.10);
  --bg-photo-fallback: #1a1814;
}
body.theme-dark .widget { background: #1a1814; }
body.theme-dark .modes {
  background: rgba(30, 28, 24, 0.62);
  border-color: rgba(255,255,255,0.10);
}
body.theme-dark .mode-side:hover { background: rgba(255,255,255,0.06); }
body.theme-dark .picker__back {
  background: rgba(30, 28, 24, 0.82);
  border-color: rgba(196,122,58,0.4);
}
body.theme-dark .eyebrow { background: #1a1814; }
body.theme-dark .picker__caption { text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
body.theme-dark .mode-dots span { background: rgba(255,255,255,0.22); }
body.theme-dark .mode-dots span.is-on { background: var(--ink); }
