/* Where - single-page status board. Minimal, airy, one quiet timeline. */

:root {
  --bg: #0c0e13;
  --surface: #141722;
  --line: #262c3d;
  --text: #edeff5;
  --muted: #7e8699;
  --faint: #4a5165;
  --on_work: #3ddc84;
  --lunch: #ffb648;
  --on_text: #5eb1ff;
  --off_work: #7c8599;
  --custom: #b18aff;
  --accent: var(--off_work);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --line: #dcdfe8;
    --text: #1c2130;
    --muted: #6d7488;
    --faint: #b3b9c9;
    --on_work: #12a35a;
    --lunch: #d97a06;
    --on_text: #2277d4;
    --off_work: #8a93a9;
    --custom: #8a5cf5;
  }
}

body.status-on_work { --accent: var(--on_work); }
body.status-lunch   { --accent: var(--lunch); }
body.status-on_text { --accent: var(--on_text); }
body.status-custom  { --accent: var(--custom); }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(55rem 30rem at 50% -14rem,
      color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%),
    var(--bg);
}

.board {
  max-width: 56rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 9vh, 6rem) 1.5rem 2rem;
}

/* ---- Current status, whispered in the middle ---- */

.now { text-align: center; }

.now-label {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--faint);
}

.now-status {
  margin: 0.6rem 0 0;
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 300;
  letter-spacing: -0.02em;
}

.now-symbol {
  font-size: 0.72em;
  margin-right: 0.35rem;
  vertical-align: 0.06em;
}

.now-since {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.telegram-error {
  width: fit-content;
  margin: 1.4rem auto 0;
  padding: 0.5rem 1rem;
  border: 1px solid color-mix(in srgb, #e5484d 40%, var(--line));
  border-radius: 2rem;
  background: color-mix(in srgb, #e5484d 10%, var(--surface));
  font-size: 0.85rem;
}

/* ---- Actions: quiet pills ---- */

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.8rem;
}

.action {
  --a: var(--off_work);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.action.status-on_work { --a: var(--on_work); }
.action.status-lunch   { --a: var(--lunch); }
.action.status-on_text { --a: var(--on_text); }

.action:hover:not(:disabled) {
  color: var(--text);
  border-color: color-mix(in srgb, var(--a) 55%, var(--line));
  background: color-mix(in srgb, var(--a) 8%, transparent);
}

.action:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }

.action:disabled { cursor: default; }

.action.is-current {
  color: var(--text);
  border-color: color-mix(in srgb, var(--a) 60%, var(--line));
  background: color-mix(in srgb, var(--a) 12%, transparent);
}

.action-symbol { font-size: 1rem; line-height: 1; }

/* ---- Custom status: one quiet line of input ---- */

.custom-form {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.9rem auto 0;
  max-width: 24rem;
}

.custom-text,
.custom-symbol {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  min-width: 0;
}

.custom-text { flex: 1; }

.custom-symbol {
  width: 3.2rem;
  text-align: center;
  padding-inline: 0.4rem;
}

.custom-text::placeholder,
.custom-symbol::placeholder { color: var(--faint); }

.custom-text:focus-visible,
.custom-symbol:focus-visible,
.custom-go:focus-visible {
  outline: 2px solid var(--custom);
  outline-offset: 2px;
}

.custom-go {
  width: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.custom-go:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--custom) 55%, var(--line));
  background: color-mix(in srgb, var(--custom) 8%, transparent);
}

/* ---- The 24h line ---- */

.day { margin-top: clamp(3rem, 9vh, 5.5rem); }

.day-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0.2rem 0.4rem;
}

.day h2 {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--faint);
}

.day-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tool {
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.45rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tool:hover { color: var(--text); border-color: var(--muted); }

.tool-clear {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 0.4rem;
}

.tool-clear:hover { color: #e5484d; border-color: color-mix(in srgb, #e5484d 55%, var(--line)); }

/* the scroll viewport, with fades pinned to its edges */
.day-view { position: relative; }

.day-view::before,
.day-view::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3rem;
  z-index: 50;
  pointer-events: none;
}

/* the past always dissolves... */
.day-view::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg), transparent);
}

/* ...the "now" end only when it's out of view */
.day-view::after {
  right: 0;
  background: linear-gradient(270deg, var(--bg), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.day-view.fade-r::after { opacity: 1; }

.day-scroll {
  overflow-x: auto;
  /* room for the breathing now-dot and edge pins, so nothing gets clipped */
  padding-inline: 1.2rem;
  /* scrollbar never shows: drag, swipe or zoom instead */
  scrollbar-width: none;
  cursor: grab;
  /* native horizontal pan, pinch goes to the zoom script */
  touch-action: pan-x;
}

.day-scroll::-webkit-scrollbar { display: none; }

.day-scroll.dragging { cursor: grabbing; user-select: none; }

.day-inner {
  position: relative;
  min-width: 44rem;
  height: 11rem;
}

/* the axis itself */
.axis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.4rem;
  height: 1px;
  background: var(--line);
}

/* "now": a breathing dot at the right end of the axis; sits above the
   viewport-edge fade so its colour stays vivid */
.now-dot {
  position: absolute;
  right: 0;
  bottom: 2.4rem;
  width: 0.5rem;
  height: 0.5rem;
  transform: translate(50%, 50%);
  border-radius: 50%;
  background: var(--accent);
  z-index: 60;
  animation: breathe 2.6s ease-out infinite;
}

@keyframes breathe {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  70%  { box-shadow: 0 0 0 0.7rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .now-dot { animation: none; }
}

/* hour ticks below the axis */
.tick {
  position: absolute;
  bottom: 2.4rem;
  width: 1px;
  height: 0.4rem;
  transform: translate(-50%, 100%);
  background: var(--faint);
  opacity: 0.55;
}

.tick.major { height: 0.65rem; opacity: 1; }

.tick-label {
  position: absolute;
  top: 0.85rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--faint);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

/* minor hour labels appear once the zoom gives them room */
.tick:not(.major) .tick-label { display: none; }
.day-inner.zoomed .tick .tick-label { display: block; }

/* status pins above the axis */
.pin {
  position: absolute;
  bottom: 2.4rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin { --a: var(--off_work); }
.pin.status-on_work { --a: var(--on_work); }
.pin.status-lunch   { --a: var(--lunch); }
.pin.status-on_text { --a: var(--on_text); }
.pin.status-custom  { --a: var(--custom); }

/* staggered stem heights so neighbouring pins breathe */
.pin.lvl-0 .pin-stem { height: 2.1rem; }
.pin.lvl-1 .pin-stem { height: 3.3rem; }
.pin.lvl-2 .pin-stem { height: 4.5rem; }

.pin-stem {
  order: 3;
  width: 1px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--a) 65%, transparent), transparent);
}

.pin-head {
  order: 2;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--a);
  box-shadow: 0 0 0.6rem color-mix(in srgb, var(--a) 45%, transparent);
  transition: transform 0.15s;
}

.pin:hover .pin-head { transform: scale(1.45); }
.pin:hover { z-index: 99 !important; }

/* hover popup */
.pin-pop {
  order: 1;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -0.45rem);
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface);
  box-shadow: 0 12px 30px -14px rgb(0 0 0 / 0.6);
  font-size: 0.82rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
}

.pin-pop time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.4rem;
}

.pin:hover .pin-pop { opacity: 1; visibility: visible; }

/* keep popups inside the timeline near its ends */
.pin.edge-l .pin-pop { left: 0; transform: translate(-0.5rem, -0.45rem); }
.pin.edge-r .pin-pop { left: auto; right: 0; transform: translate(0.5rem, -0.45rem); }

.day-empty {
  position: absolute;
  left: 50%;
  bottom: 4.6rem;
  transform: translateX(-50%);
  margin: 0;
  color: var(--faint);
  font-size: 0.85rem;
  font-style: italic;
  letter-spacing: 0.06em;
}

/* ---- Footer ---- */

.colophon {
  margin-top: clamp(3rem, 8vh, 5rem);
  text-align: center;
  color: color-mix(in srgb, var(--faint) 60%, transparent);
  font-size: 0.7rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
}
