:root {
  --wall: #e8e2d6;
  --wall-shade: #d6cebf;
  /* The panel matches the clock's bezel in both themes, like an instrument card beside it. */
  --card: #17171a;
  --card-line: #2c2c32;
  --ink: #f2ead8;
  --ink-dim: #8d8d96;
  --accent: #e53935;
  --live: #4caf7d;
  --col-w: clamp(520px, 40vw, 660px); /* the column holding both cards */
  --card-gap: 16px;  /* between the two cards */
  --gap: clamp(48px, 5vw, 96px); /* breathing room between dial and panels */
}

@media (prefers-color-scheme: dark) {
  :root {
    --wall: #1d1e22;
    --wall-shade: #141518;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 40% 40%, var(--wall), var(--wall-shade));
  font: 13px/1.4 -apple-system, Helvetica, sans-serif;
  color: var(--ink);
}

.wall {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding: 16px;
}

/* Two columns: the dial on the left; World time above the tools card on the right. */
#clock {
  flex: none;
  width: min(94vh, calc(100vw - var(--col-w) - var(--gap) - 32px));
  height: auto;
}

.side-col {
  flex: none;
  width: var(--col-w);
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
  /* Anchor to the top, level with the dial. World time stays put; the tools card below
     grows downward when hand control or a preview opens. */
  align-self: flex-start;
  margin-top: max(0px, calc(3vh - 16px));
}

/* Cards size to their content and never scroll inside; the world time list always shows
   all eight cities. */
.side { flex: none; width: 100%; }
.side {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: 0 12px 40px #0006;
}

/* Phones, tablets and narrow windows get a message instead of the site. Same rule as
   hands.js: needs a mouse/trackpad and at least 900px of width. Resizing a window past
   the line swaps between the two live. */
.small-screen { display: none; }

@media (max-width: 899px), (hover: none), (pointer: coarse) {
  .wall { display: none; }
  .small-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 24px 16px;
    text-align: center;
    color: var(--ink);
    background: var(--card);
  }
  .small-screen svg { width: 72px; height: 72px; margin-bottom: 16px; color: var(--ink-dim); }
  .small-screen h1 { margin: 0; font: 400 22px/1.3 Georgia, "Times New Roman", serif; letter-spacing: 0.5px; }
  .small-screen p { margin: 8px 0 0; max-width: 32ch; color: var(--ink-dim); font-size: 15px; line-height: 1.5; }
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--card-line);
}

.side-title {
  margin: 0;
  font: 600 11px/1 -apple-system, Helvetica, sans-serif;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-dim);
}

.side-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--live);
  white-space: nowrap;
}

.side-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.side-state.is-travelling { color: var(--accent); }

/* The eight cities in two rows of four, west to east, same colours as the rings. */
.side-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* One tile per city: name, time, then date and offset from you. */
.side-row {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 6px 8px 7px 10px;
  border-left: 4px solid var(--zone);
  border-radius: 2px 8px 8px 2px;
  background: #ffffff05;
  line-height: 1.25;
}

.side-city {
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-time {
  margin: 1px 0 2px;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.side-time-row { display: flex; align-items: flex-start; gap: 3px; white-space: nowrap; }
.side-day { margin-top: 3px; font-size: 11px; font-weight: 700; color: var(--ink-dim); line-height: 1; }
.side-day:empty { display: none; }

.side-meta {
  display: flex;
  flex-direction: column;
  color: var(--ink-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.side-meta > span { overflow: hidden; text-overflow: ellipsis; }

.side-row.is-you { background: #ffffff10; }
.side-row.is-you .side-rel { color: var(--ink); font-weight: 600; }

/* While the dial is away from now, times read in the accent colour so it's obvious. */
body.travelling .side-time { color: var(--accent); }

/* Tools card: the text box on top, then Hand control and Back to now side by side, then
   the camera preview. hands.js's wrapper uses display: contents so its button and preview
   join this grid directly. */
.side-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 16px;
}

.side-tools:not(:has(> :not([hidden]))) { display: none; }
/* Button styles below set display, which would otherwise beat the hidden attribute. */
.side [hidden] { display: none !important; }

.side button {
  font: inherit;
  color: inherit;
  border: 1px solid #3b3b41;
  background: #1f1f23;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.side button:hover { border-color: var(--ink-dim); }
.side button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.side-now { color: var(--accent); border-color: var(--accent) !important; }

/* --- Hand control (desktop only; hands.js adds these into .side-tools) ------- */

.side-tools > .ask { grid-column: 1 / -1; }
.side-tools > .hands { display: contents; }
.side-tools .hands-toggle, .side-tools .side-now { order: 1; white-space: nowrap; }
.side-tools .hands-panel { order: 2; grid-column: 1 / -1; }
.side-tools .preview { order: 3; grid-column: 1 / -1; }
.side-tools .meeting { order: 4; grid-column: 1 / -1; }
/* A dropped image and a meeting at the same time: share the row instead of stacking. */
.side-tools:has(.preview:not([hidden])):has(.meeting:not([hidden])) :is(.preview, .meeting) { grid-column: auto; }
/* Whichever of the two buttons is alone takes the full width. */
.side-tools:has(.side-now[hidden]) .hands-toggle,
.side-tools:not(:has(.hands)) .side-now { grid-column: 1 / -1; }

.hands-toggle[aria-pressed="true"] { border-color: var(--accent) !important; }


/* Camera preview on the left, status and tips beside it, so the card stays short. */
.hands-panel:not([hidden]) {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: auto 1fr;
  column-gap: 12px;
  align-items: start;
}

.hands-preview {
  grid-row: 1 / span 2;
  display: block;
  width: 200px;
  height: auto;
  border-radius: 8px;
  background: #000;
}

.hands-status { margin: 0 0 4px; font-weight: 600; font-size: 12px; }
.hands-help { font-size: 12px; }
.hands-help { margin: 0; padding-left: 18px; color: var(--ink-dim); }
.hands-help b { color: var(--ink); font-weight: 600; }

/* Fallback if the panel is missing: float in the corner as before. */
.hands.is-floating { position: fixed; right: 20px; bottom: 20px; width: 260px; }

/* While the dial is held, give the bezel a faint red rim. */
/* box-shadow, not filter: a filter would re-rasterise the whole dial every frame. */
#clock { border-radius: 50%; transition: box-shadow 0.2s; }
body.grabbing #clock { box-shadow: 0 0 0 3px #e5393599, 0 0 24px #e5393555; }

/* While the dial is turning, fade the fine ticks and :30 labels. Many concentric rings
   of small repeating marks moving together read as spiralling motion; hour labels stay. */
#clock .minor { transition: opacity 0.25s; }
body.grabbing #clock .minor,
body.moving #clock .minor { opacity: 0.15; }

@media (prefers-reduced-motion: reduce) {
  #clock .minor { transition: none; }
}

/* --- Dropped times ----------------------------------------------------------- */

.ask { display: flex; flex-direction: column; gap: 6px; }
.ask-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } /* placeholder says it; kept for screen readers */
.ask-row { display: flex; gap: 6px; }

.ask-field { position: relative; flex: 1; min-width: 0; display: flex; }

.ask-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: inherit;
  background: #0f0f11;
  border: 1px solid #3b3b41;
  border-radius: 8px;
  padding: 7px 10px;
}

.ask-field:has(.ask-clear:not([hidden])) .ask-input { padding-right: 28px; }
.side .ask-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  translate: 0 -50%;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--ink-dim);
  font-size: 16px;
  line-height: 1;
}
.side .ask-clear:hover { color: var(--ink); background: #ffffff14; }

.ask-input.has-file { color: var(--ink); font-weight: 600; text-overflow: ellipsis; cursor: default; }

.ask-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask-input:disabled, .side .ask-go:disabled { opacity: 0.45; cursor: not-allowed; }
.side .ask-go { width: auto; border-radius: 8px; padding: 7px 12px; }

.ask-status { margin: 0; min-height: 0; font-size: 12px; color: var(--ink-dim); }
.ask-status:empty { display: none; }
.ask-status[data-kind="error"] { color: #ff8a80; }
.ask-status[data-kind="busy"]::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

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

/* Full-page target while dragging a file over the window. */
.drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: #0e0e10cc;
  pointer-events: none;
  font: 400 24px/1 Georgia, "Times New Roman", serif;
  letter-spacing: 1px;
  color: var(--ink);
}

.drop-overlay[hidden] { display: none; }

/* Under hand control: what was dropped, and which time from it the dial is showing. */
/* Preview and found time side by side; whichever is alone takes the full width. */
.preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; align-items: start; }

.preview-img {
  display: block;
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: 8px;
  background: #0f0f11;
  border: 1px solid var(--card-line);
}

/* A text file: its first lines, faded out at the bottom instead of scrolling. */
.preview-text {
  margin: 0;
  max-height: 120px;
  overflow: hidden;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0f0f11;
  border: 1px solid var(--card-line);
  font: 11px/1.45 ui-monospace, Menlo, monospace;
  color: var(--ink-dim);
  white-space: pre-wrap;
  word-break: break-word;
  mask-image: linear-gradient(#000 70%, transparent);
}

.found {
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: #e5393514;
}

.found-top { display: flex; align-items: center; gap: 6px; }
.found-label { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.found-source { margin-top: 2px; color: var(--ink-dim); font-size: 12px; font-variant-numeric: tabular-nums; }

.found-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.side .found button { width: auto; padding: 0 8px; line-height: 1.4; font-size: 15px; }

/* --- "What can it do?" ---------------------------------------------------------- */

/* Top bar above World time: a way back to the portfolio, and the feature guide. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.back-link {
  color: var(--ink-dim);
  font: 600 13px/1 -apple-system, Helvetica, sans-serif;
  text-decoration: none;
  padding: 8px 2px;
  border-radius: 6px;
}
.back-link:hover { color: var(--ink); }
.back-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.small-screen .back-link { margin-top: 12px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.tour-open {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font: 600 13px/1 -apple-system, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #3b3b41;
  border-radius: 999px;
  box-shadow: 0 8px 24px #0006;
  cursor: pointer;
}
.tour-open span { color: var(--accent); }
.tour-open:hover { border-color: var(--ink-dim); }
.tour-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A soft pulse until it has been opened once. */
.tour-open.is-new { animation: tour-pulse 2.4s ease-out infinite; }
@keyframes tour-pulse {
  0% { box-shadow: 0 8px 24px #0006, 0 0 0 0 #e5393566; }
  70%, 100% { box-shadow: 0 8px 24px #0006, 0 0 0 12px #e5393500; }
}
@media (prefers-reduced-motion: reduce) { .tour-open.is-new { animation: none; } }

.tour {
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 0;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: 0 24px 80px #000a;
}
.tour::backdrop { background: #0009; }

.tour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--card-line);
}
.tour-head h2 { margin: 0; font: 400 20px/1.2 Georgia, "Times New Roman", serif; letter-spacing: 0.3px; }

.tour { overflow-y: auto; }
.tour-intro { margin: 14px 20px 0; color: var(--ink-dim); line-height: 1.5; }
/* Two columns of feature tiles; the last one spans both. */
.tour-list {
  list-style: none;
  margin: 0;
  padding: 14px 20px 20px;
  counter-reset: tour;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tour-list li {
  counter-increment: tour;
  position: relative;
  padding: 14px 16px 16px 50px;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  background: #ffffff05;
}
.tour-list li:last-child:nth-child(odd) { grid-column: 1 / -1; }
.tour-list li::before {
  content: counter(tour);
  position: absolute;
  left: 16px;
  top: 15px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: #2a2a30;
  color: var(--ink);
}
.tour-list h3 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tour-list p { margin: 0; color: var(--ink-dim); line-height: 1.5; }
.tour-list p b, .tour-list p i { color: var(--ink); }
.tour-list .red { color: var(--accent); }

.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid #e5393566;
  border-radius: 999px;
  padding: 2px 7px;
}

.tour-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tour-try {
  margin-top: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: #1f1f23;
  border: 1px solid #3b3b41;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}
.tour-try:hover:not(:disabled) { border-color: var(--accent); }
.tour-try:disabled { opacity: 0.45; cursor: not-allowed; }
.tour-try:focus-visible, .tour-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tour-close {
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-dim);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.tour-close:hover { color: var(--ink); background: #ffffff14; }

kbd {
  font: 600 11px/1 ui-monospace, Menlo, monospace;
  color: var(--ink);
  background: #2a2a30;
  border: 1px solid #3b3b41;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 5px;
}
code { font: 12px ui-monospace, Menlo, monospace; color: var(--ink); }
.tour-head h2:focus { outline: none; }

/* --- Meeting finder ---------------------------------------------------------------- */

/* On the dial: working-hour arcs appear on the rings taking part; the others fade back. */
#clock .work { display: none; }
#clock.planning .band.is-in .work { display: inline; }
#clock .band, #clock .lane { transition: opacity 0.3s; }
#clock.planning .band:not(.is-in),
#clock.planning .lane:not(.is-in) { opacity: 0.22; }

/* In the tools card. */
.meeting {
  padding: 10px 12px 12px;
  border: 1px solid #3fbf7f;
  border-radius: 10px;
  background: #3fbf7f12;
}
.meeting-top { display: flex; align-items: center; gap: 6px; }
.meeting-label { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .meeting-close { width: auto; padding: 0 8px; line-height: 1.4; font-size: 15px; border-color: transparent; background: none; color: var(--ink-dim); }
.meeting-when { margin-top: 2px; font-weight: 600; color: #7fdcaa; font-variant-numeric: tabular-nums; }
.meeting-note { margin: 6px 0 8px; font-size: 12px; line-height: 1.45; color: var(--ink-dim); }
.meeting-people { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--card-line); }
.meeting-people li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.meeting-city { font-weight: 600; }
.meeting-time { color: var(--ink-dim); white-space: nowrap; }
.meeting-people li.is-outside .meeting-time { color: #ffb74d; }
