/* Night shift: the agents work while you are away. A calm night sky, quiet
   text, and warm lamp light only on what needs you. */

@font-face {
  font-family: "Bricolage";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  src: url(/static/fonts/bricolage-grotesque-latin.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  src: url(/static/fonts/bricolage-grotesque-latin-ext.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  --night: #0e1322;
  --deep: #0a0e1a;      /* inputs and the log, below the page */
  --dusk: #151c2e;      /* panels, above the page */
  --dusk-hover: #1a2236;
  --haze: #283149;      /* lines */
  --moon: #dce1ec;      /* text */
  --mist: #8e97ae;      /* secondary text */
  --lamp: #f2b54a;      /* what needs you, main actions */
  --lamp-ink: #241a06;
  --running: #8ab4ff;
  --done: #74c69d;
  --failed: #f27a6e;

  --sans: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Type scale, ratio 1.25 from 15px */
  --t-small: 0.8rem;
  --t-meta: 0.875rem;
  --t-body: 0.9375rem;
  --t-lead: 1.0625rem;
  --t-h2: 1.1875rem;
  --t-h1: 1.875rem;
  --t-display: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--moon);
  background: var(--night);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--haze); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--mono); font-size: 0.9em; }

h1, h2 { font-stretch: 82%; letter-spacing: -0.01em; line-height: 1.15; }
h1 { font-size: var(--t-h1); font-weight: 700; margin: 0; }
h2 { font-size: var(--t-h2); font-weight: 650; margin: 0 0 12px; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap;
  padding: 14px 32px; border-bottom: 1px solid var(--haze);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 1.125rem; font-weight: 700; font-stretch: 80%; text-decoration: none;
}
.top-actions { display: flex; align-items: center; gap: 20px; margin-left: auto; }
.top-actions form { margin: 0; }
.test-banner {
  padding: 8px 32px; font-size: var(--t-meta); color: var(--lamp);
  background: repeating-linear-gradient(-45deg, rgba(242, 181, 74, 0.07) 0 12px, transparent 12px 24px);
  border-bottom: 1px solid rgba(242, 181, 74, 0.25);
}

main { max-width: 1240px; margin: 0 auto; padding: 32px; }

/* Controls */
label { display: block; font-size: var(--t-meta); font-weight: 600; margin: 0 0 6px; }
input, textarea {
  display: block; width: 100%; padding: 10px 12px;
  font: inherit; color: var(--moon); background: var(--deep);
  border: 1px solid var(--haze); border-radius: 8px;
}
input::placeholder, textarea::placeholder { color: #5f6884; }
input:focus, textarea:focus { outline: none; border-color: var(--lamp); box-shadow: 0 0 0 3px rgba(242, 181, 74, 0.15); }
textarea { resize: vertical; line-height: 1.5; }
textarea[readonly] { color: var(--mist); }

button {
  font: inherit; font-weight: 650; padding: 9px 16px; cursor: pointer;
  color: var(--lamp-ink); background: var(--lamp); border: 1px solid var(--lamp); border-radius: 8px;
}
button:hover { background: #f7c66a; border-color: #f7c66a; }
button.secondary { color: var(--moon); background: transparent; border-color: var(--haze); }
button.secondary:hover { background: var(--dusk-hover); }
button.danger { color: var(--failed); background: transparent; border-color: rgba(242, 122, 110, 0.5); }
button.danger:hover { background: rgba(242, 122, 110, 0.12); }
button.link { padding: 0; font-weight: 500; color: var(--mist); background: none; border: 0; }
button.link:hover { color: var(--moon); }
button.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.hint, .muted { color: var(--mist); }
.hint { font-size: var(--t-meta); margin: 6px 0 16px; }
.error { color: var(--failed); margin: 0 0 12px; }
.panel { background: var(--dusk); border: 1px solid var(--haze); border-radius: 14px; padding: 20px; }

/* Status: a dot and a word. Running tasks pulse; nothing else moves. */
.state {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: var(--t-meta); font-weight: 550; color: var(--mist);
}
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.state.running { color: var(--running); }
.state.running::before { animation: pulse 2s ease-out infinite; }
.state.done { color: var(--done); }
.state.failed { color: var(--failed); }
.state.waiting { color: var(--lamp); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(138, 180, 255, 0.55); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(138, 180, 255, 0); }
}
@media (prefers-reduced-motion: reduce) { .state.running::before { animation: none; } }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 8px; font-size: var(--t-meta); color: var(--mist); }
.meta a { color: var(--moon); font-weight: 650; }

/* Dashboard */
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 48px; align-items: start; }
.main-col > section + section, .main-col > .summary-line + section { margin-top: 40px; }
.summary-line { font-size: var(--t-display); font-weight: 700; font-stretch: 78%; letter-spacing: -0.02em; }
.side-col { position: sticky; top: 24px; }
.new-task h2 { margin-bottom: 18px; }
.new-task input { margin-bottom: 0; }
.new-task textarea { margin-bottom: 16px; }

/* What needs you is the one lit thing on the page. */
.needs {
  background: linear-gradient(180deg, rgba(242, 181, 74, 0.07), rgba(242, 181, 74, 0.02));
  border: 1px solid rgba(242, 181, 74, 0.45); border-radius: 16px; padding: 6px 22px;
  box-shadow: 0 0 0 4px rgba(242, 181, 74, 0.05), 0 18px 48px -20px rgba(242, 181, 74, 0.35);
}
.needs h2 { color: var(--lamp); margin: 16px 0 4px; }
.ask { padding: 18px 0; }
.ask + .ask { border-top: 1px solid rgba(242, 181, 74, 0.2); }
.ask .text { margin: 0 0 12px; font-size: var(--t-lead); white-space: pre-wrap; overflow-wrap: anywhere; }
.ask.blocker .text { color: #f6d2ce; }
.ask .hint { margin-top: -4px; }
.task-page > .needs { margin-bottom: 32px; }

.lesson { padding: 16px 0; border-top: 1px solid var(--haze); }
.lessons .hint { margin-top: -4px; }

/* Task list */
.table-wrap { overflow-x: auto; }
.tasks { width: 100%; border-collapse: collapse; }
.tasks th {
  text-align: left; font-size: var(--t-small); font-weight: 600; color: var(--mist);
  padding: 0 14px 10px; border-bottom: 1px solid var(--haze);
}
.tasks td { padding: 14px; border-bottom: 1px solid var(--haze); vertical-align: top; }
.tasks tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.tasks th:first-child, .tasks td:first-child { padding-left: 0; }
.tasks .service a { font-weight: 650; font-size: var(--t-lead); text-decoration: none; }
.tasks .service a:hover { text-decoration: underline; }
.tasks .status .state { display: flex; }
.tasks .status .state + .state { margin-top: 4px; }
.tasks .step { min-width: 9em; }
.tasks .col-created { color: var(--mist); white-space: nowrap; }
.tasks .outcome { color: var(--mist); font-size: var(--t-meta); min-width: 13em; overflow-wrap: anywhere; }
.tasks .empty td { color: var(--mist); padding-left: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Task page */
.back { display: inline-block; margin-bottom: 14px; font-size: var(--t-meta); color: var(--mist); text-decoration: none; }
.back::before { content: "‹"; margin-right: 6px; }
.back:hover { color: var(--moon); }
.task-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 28px; }
.task-head h1 { font-size: var(--t-display); font-stretch: 78%; }
.task-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.details dl { margin: 0; }
.details dt { font-size: var(--t-small); font-weight: 600; color: var(--mist); margin-top: 16px; }
.details dt:first-child { margin-top: 0; }
.details dd { margin: 4px 0 0; overflow-wrap: anywhere; }
#outcome:empty::before { content: "Not finished yet"; color: var(--mist); }
.details .num { text-align: left; }
.details form { margin-top: 20px; }
.request { white-space: pre-wrap; color: var(--mist); font-size: var(--t-meta); }
.usage { margin: 0 0 6px; font-size: var(--t-meta); color: var(--mist); }
.usage strong { display: block; color: var(--moon); font-weight: 600; }
pre#log {
  margin: 0; padding: 16px 18px; max-height: 72vh; overflow: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: #b9c1d4;
  background: var(--deep); border: 1px solid var(--haze); border-radius: 12px;
  white-space: pre-wrap; word-break: break-word;
}

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; padding: 28px; }
.login h1 { font-size: var(--t-h1); font-stretch: 80%; }
.login input { margin-bottom: 18px; }

/* Sound toggle and the "changed while typing" note, added by the script */
.top .sound { font-size: var(--t-meta); }
.top .sound.blocked { color: var(--lamp); font-weight: 650; }
.banner {
  position: fixed; right: 20px; bottom: 20px; padding: 12px 16px; border-radius: 10px;
  color: var(--lamp-ink); background: var(--lamp); box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
}
.banner a { font-weight: 700; text-decoration-color: currentColor; }

/* Narrow screens: one column; the task list becomes stacked rows. */
@media (max-width: 960px) {
  .dashboard, .task-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .side-col { position: static; }
  .task-grid .details { order: -1; }
}
@media (max-width: 640px) {
  main { padding: 20px 16px 40px; }
  .top, .test-banner { padding-left: 16px; padding-right: 16px; }
  .needs { padding: 2px 16px; }
  .tasks thead { display: none; }
  .tasks, .tasks tbody { display: block; }
  .tasks tr {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
    grid-template-areas: "service cost" "status step" "outcome outcome";
    padding: 14px 0; border-bottom: 1px solid var(--haze);
  }
  .tasks tr.empty { display: block; }
  .tasks td { padding: 0; border: 0; }
  .tasks td.service { grid-area: service; }
  .tasks td.num { grid-area: cost; }
  .tasks td.status { grid-area: status; display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .tasks .status .state + .state { margin-top: 0; }
  .tasks td.step { grid-area: step; color: var(--mist); text-align: right; min-width: 0; }
  .tasks td.outcome { grid-area: outcome; min-width: 0; }
  .tasks .col-created { display: none; }
}
