/* christofferonleave.se — Night shift.
   Cool, precise and dark: deep navy night, two quiet glass surfaces and one
   lit stretch of the year. The leave runs from mint (15 April) to indigo
   (15 November); coral is reserved for "now" and for the person asking.
   Sans throughout, mono only for small technical labels. */

:root {
  color-scheme: dark;
  --bg: #080b12;
  --bg-2: #0c111b;
  --off: #121826;
  --off-line: #19212f;
  --line: #1c2433;
  --line-strong: #2b3547;
  --ink: #f2f5fa;
  --text: #d5dce7;
  --soft: #b0bacb;
  --muted: #8892a6;
  --c-start: #4be3c4;  /* 15 April: the first morning off */
  --c-mid: #58b2ec;
  --c-end: #6d7dff;    /* 15 November: back at 07:00 */
  --now: #ff7a5c;
  --spent: #172636;
  --spent-line: #20364a;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 18px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  font: 16px/1.6 var(--sans);
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-width: 320px; overflow-x: clip;
  background:
    radial-gradient(1100px 620px at 78% -180px, rgba(84, 118, 255, .17), transparent 70%),
    radial-gradient(760px 480px at 8% -120px, rgba(75, 227, 196, .075), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
}
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
::selection { background: rgba(75, 227, 196, .3); color: #fff; }
:focus-visible { outline: 2px solid var(--c-start); outline-offset: 3px; border-radius: 6px; }
h1, h2, p, figure, ol { margin: 0; }
h1, h2, p { overflow-wrap: break-word; }

.skip { position: absolute; top: -100px; left: 16px; z-index: 50; padding: 12px 16px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 600; }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter) clamp(56px, 9vw, 112px); }

/* The two surfaces on the page: the year and the conversation. */
.panel {
  min-width: 0;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid rgba(148, 170, 220, .13);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(24, 32, 50, .72), rgba(12, 17, 28, .78));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 28px 70px -36px rgba(0, 0, 0, .85);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* ---------- Header ---------- */
.masthead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
/* One lit day as the mark. */
.brand::before { content: ""; flex-shrink: 0; width: 14px; height: 14px; border-radius: 4px; background: linear-gradient(135deg, var(--c-start), var(--c-end)); box-shadow: 0 0 14px rgba(88, 178, 236, .35); }
.nav { display: flex; gap: 24px; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; color: var(--soft); text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 6px; text-decoration-thickness: 1.5px; transition: color .2s, text-decoration-color .2s; }
.nav a:hover { color: var(--ink); text-decoration-color: var(--c-start); }

/* ---------- Hero ---------- */
.hero { display: grid; gap: 32px; padding: clamp(28px, 5vw, 56px) 0 clamp(56px, 8vw, 96px); }
.count { container-type: inline-size; min-width: 0; }
.kicker { font-size: clamp(17px, 15px + .4vw, 20px); font-weight: 500; line-height: 1.35; letter-spacing: -.005em; color: var(--soft); }
.days-line { display: flex; align-items: baseline; gap: 0 .1em; margin-top: 12px; }
.days {
  font: 650 clamp(96px, 19vw, 240px)/.86 var(--sans);
  font-size: min(240px, 44cqi);
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
  margin-left: -.05em;
  padding-right: .06em; /* cancels the trailing letter-spacing before "days" */
  color: var(--ink);
  transition: color .4s;
}
/* A little cold light on the number once it is live. */
.hero:not(.is-loading) .days {
  background: linear-gradient(180deg, #ffffff 25%, #b9c6e0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.days-word { font-size: clamp(20px, 6.5cqi, 32px); font-weight: 600; line-height: 1; letter-spacing: -.015em; color: var(--c-start); padding-left: .3em; }

.hms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 30rem; margin-top: clamp(22px, 3vw, 32px); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.unit { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px 0; font: 12px/1.2 var(--mono); letter-spacing: .02em; color: var(--muted); }
.unit + .unit { padding-left: clamp(12px, 3vw, 22px); border-left: 1px solid var(--line); }
.unit strong { font: 600 clamp(26px, 21px + 1vw, 34px)/1 var(--sans); letter-spacing: -.035em; font-variant-numeric: tabular-nums; color: var(--ink); transition: color .4s; }
.counting-aside { margin-top: 16px; font-size: 16px; font-style: italic; line-height: 1.4; color: var(--soft); }
/* Before the first tick: static, dimmed placeholders. No pulsing. */
.is-loading .days, .is-loading .unit strong { color: var(--muted); }

/* ---------- The year ---------- */
.year-caption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 20px; padding-bottom: 16px; margin-bottom: clamp(16px, 2.4vw, 22px); border-bottom: 1px solid var(--line); }
.year-length { font-size: 17px; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
.year-dates { font-size: 14px; line-height: 1.5; color: var(--soft); }

/* Cell sizes per breakpoint. Columns are 1fr; rows are fixed so the grid
   holds its height before app.js fills it. */
.cal { --ch: 6px; --rg: 2px; --cg: 3px; --glow: 1; }
.cal-edges, .cal-grid, .cal-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--cg); }

.cal-edges { margin-bottom: 8px; font: 500 11px/1.3 var(--mono); letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.cal-edge { position: relative; padding-bottom: 9px; white-space: nowrap; }
.cal-edge::after { content: ""; position: absolute; bottom: 0; width: 1px; height: 6px; }
.cal-edge-start { grid-column: 4 / 7; justify-self: start; color: var(--c-start); }
.cal-edge-start::after { left: 0; background: var(--c-start); }
.cal-edge-end { grid-column: 7 / 12; justify-self: end; color: #9aa6ff; }
.cal-edge-end::after { right: 0; background: var(--c-end); }

.cal-grid { position: relative; isolation: isolate; height: calc(31 * var(--ch) + 30 * var(--rg)); }
/* One cool light behind April–November, not a shadow per cell. It fades
   as the leave is used up (--glow from app.js). */
.cal-grid::before {
  content: ""; position: absolute; z-index: -1; top: -14%; bottom: -14%;
  left: calc((100% - 11 * var(--cg)) / 12 * 3 + 3 * var(--cg));
  width: calc((100% - 11 * var(--cg)) / 12 * 8 + 7 * var(--cg));
  background:
    radial-gradient(closest-side at 30% 50%, rgba(75, 227, 196, .13), transparent),
    radial-gradient(closest-side at 72% 50%, rgba(109, 125, 255, .16), transparent);
  opacity: calc(.15 + .85 * var(--glow));
  transform: scaleX(1.15);
  pointer-events: none;
}
.cal-month { display: grid; grid-auto-rows: var(--ch); row-gap: var(--rg); min-width: 0; }
.cal-month > span { position: relative; border-radius: 2px; background: var(--off); box-shadow: inset 0 0 0 1px var(--off-line); }
.cal-month > .on, .cal-month > .part { --cell: var(--c-mid); }
.cal-month > .on { background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 70%), var(--cell); box-shadow: none; }
.cal-month > .spent { background: var(--spent); box-shadow: inset 0 0 0 1px var(--spent-line); }
/* 15 Nov: lit only from 00:00 to 07:00, i.e. the first 29 % of the cell. */
.cal-month > .part::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--a, 0%); right: calc(100% - var(--b, 100%)); border-radius: 2px 0 0 2px; background: var(--cell); }
.cal-month > .part.spent::after { background: var(--spent-line); }
.cal-month > .today { z-index: 1; outline: 1.5px solid var(--now); outline-offset: 1px; }

/* Each leave day takes its colour from its place in the leave (--i, 0–214). */
@supports (color: color-mix(in oklch, red, blue)) {
  .cal-month > .on, .cal-month > .part { --cell: color-mix(in oklch, var(--c-start), var(--c-end) calc(var(--i, 0) * 100% / 214)); }
  .cal-month > .spent { background: color-mix(in oklch, var(--cell) 24%, var(--bg-2)); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--cell) 30%, transparent); }
  .cal-month > .part.spent::after { background: color-mix(in oklch, var(--cell) 45%, var(--bg-2)); }
}

.cal-months { margin-top: 10px; padding: 0; list-style: none; font: 500 11px/1.2 var(--mono); letter-spacing: .02em; text-align: center; color: var(--muted); }
.cal-months li { min-width: 0; }
.cal-months .in { color: var(--ink); }
.m-short { display: none; }

/* ---------- Ask ---------- */
.ask { display: grid; gap: 32px; padding-top: clamp(40px, 6vw, 72px); border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.ask-intro { min-width: 0; }
.ask h2 { font-size: clamp(34px, 24px + 2.4vw, 56px); font-weight: 650; line-height: 1.04; letter-spacing: -.035em; color: var(--ink); text-wrap: balance; }

.suggestions { display: grid; margin-top: clamp(24px, 4vw, 36px); border-bottom: 1px solid var(--line); }
.suggestions button { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; padding: 12px 4px 12px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; font-size: 16px; line-height: 1.4; color: var(--soft); transition: color .2s, padding .2s var(--ease); }
.suggestions button::after { content: ""; flex-shrink: 0; width: 7px; height: 7px; margin-right: 3px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .2s var(--ease), color .2s; }
.suggestions button:hover { color: var(--ink); padding-left: 6px; }
.suggestions button:hover::after { color: var(--c-start); transform: translateX(2px) rotate(45deg); }

.chat-message { overflow-wrap: anywhere; animation: rise .3s var(--ease) both; }
.chat-message p { white-space: pre-wrap; }
.chat-message.assistant p { font-size: clamp(17px, 16px + .25vw, 19px); line-height: 1.6; color: var(--text); }
.intro-message p { color: var(--ink); font-weight: 500; letter-spacing: -.005em; }
.chat-message.user { margin-top: 28px; }
.chat-message.user p { position: relative; padding-left: 24px; font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--ink); }
.chat-message.user p::before { content: ""; position: absolute; left: 0; top: .7em; width: 12px; height: 2px; border-radius: 1px; background: var(--now); }
.chat-message.user + .chat-message { margin-top: 10px; }
.chat-message[aria-busy="true"] p { font-style: italic; color: var(--muted); }

.composer { margin-top: clamp(24px, 4vw, 36px); }
.composer label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--soft); }
.input-wrap { display: flex; align-items: flex-end; gap: 10px; padding: 6px 6px 6px 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(5, 8, 14, .6); transition: border-color .2s, box-shadow .2s; }
.input-wrap:focus-within { border-color: var(--c-start); box-shadow: 0 0 0 3px rgba(75, 227, 196, .16); }
textarea { display: block; flex: 1; min-width: 0; min-height: 80px; max-height: 240px; resize: none; padding: 10px 0; border: 0; border-radius: 0; background: transparent; font-size: 17px; line-height: 1.55; color: var(--ink); }
textarea::placeholder { color: var(--muted); }
textarea:focus, textarea:focus-visible { outline: none; }
textarea:disabled { opacity: .6; }
#send { flex-shrink: 0; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 11px; background: linear-gradient(135deg, var(--c-start), var(--c-end)); color: #06101a; transition: filter .2s, transform .2s var(--ease); }
#send svg { width: 20px; height: 20px; }
#send:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
#send:focus-visible { border-radius: 11px; }
.form-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; font: 12px/1.2 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.text-button { min-height: 44px; padding: 0 2px; border: 0; background: none; font: 14px/1.2 var(--sans); color: var(--soft); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 5px; text-decoration-thickness: 1.5px; }
.text-button:hover:not(:disabled) { color: var(--ink); text-decoration-color: var(--c-start); }
.chat-error { margin-top: 12px; padding: 10px 14px; border-radius: 10px; border: 1px solid #6b3340; background: #1c1016; font-size: 14px; color: #ffcbc2; }

.no-script { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--soft); }

/* ---------- Motion ---------- */
/* The leave lights up once, April to November, in under a second. */
.ignite .cal-month > .on:not(.spent), .ignite .cal-month > .part:not(.spent)::after { animation: ignite .45s ease-out both; animation-delay: calc(var(--i, 0) * 4ms); }
@keyframes ignite { from { opacity: .08; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Responsive ---------- */
@media (max-width: 440px) {
  .m-long { display: none; }
  .m-short { display: inline; }
  .year-dates { font-size: 13px; }
}

@media (max-width: 420px) {
  .nav .nav-countdown { display: none; }
}

@media (min-width: 600px) {
  .cal { --ch: 8px; --rg: 3px; --cg: 4px; }
  .cal-edges, .cal-months { font-size: 12px; }
}

@media (min-width: 960px) {
  .masthead { padding: 16px 0; }
  .hero { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center; gap: clamp(48px, 5vw, 72px); }
  .cal { --ch: 8px; --rg: 3px; --cg: 5px; }
  .ask { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(48px, 5vw, 72px); }
  .ask-intro { position: sticky; top: 32px; align-self: start; padding-top: clamp(16px, 3vw, 28px); }
}

@media (hover: none) {
  .suggestions button:hover { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (forced-colors: active) {
  body, .panel { background: Canvas; }
  .panel { border-color: CanvasText; }
  .brand::before { forced-color-adjust: none; background: Highlight; box-shadow: none; }
  .hero:not(.is-loading) .days { background: none; -webkit-text-fill-color: CanvasText; color: CanvasText; }
  .cal-grid { forced-color-adjust: none; }
  .cal-grid::before { display: none; }
  .cal-month > span { background: Canvas; box-shadow: inset 0 0 0 1px GrayText; }
  .cal-month > .on, .cal-month > .part::after { background: Highlight; }
  .cal-month > .spent, .cal-month > .part.spent::after { background: GrayText; }
  .cal-month > .today { outline-color: CanvasText; }
  .input-wrap:focus-within { border-color: Highlight; }
  #send { background: ButtonFace; color: ButtonText; border: 1px solid ButtonText; }
}
