/*
 * Captain's Log: colours, type, page frame and the shared controls.
 * The cream paper theme carried over from StudyDesk: warm paper surfaces, ink text,
 * a vermilion accent, small uppercase labels. Clocking in turns the lamp on.
 * Type follows a newspaper pairing: a serif for the name, headings and writing, a clean sans for the rest.
 */

@font-face { font-family: 'Hanken Grotesk'; src: url('/fonts/hanken-grotesk-latin.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Source Serif 4'; src: url('/fonts/source-serif-4-latin.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  --bg: #F6F2EA;            /* paper: page background */
  --surface: #FDFBF6;       /* raised panels, pages, dialogs */
  --well: #F0E9DB;          /* inset wells: clock housing, plain buttons, tracks */
  --ink: #191613;           /* text, solid buttons, selected */
  --ink-soft: #3A342D;
  --muted: #6E6558;         /* secondary text */
  --hint: #7A7062;          /* placeholders */
  --faint: #8A7F6E;         /* inactive figures, input edges */
  --disabled: #A69C8C;
  --line: #C9C0AE;          /* borders */
  --line-soft: #E4DDCC;     /* row separators, panel edges */
  --edge: #8A7F6E;          /* inputs and tick boxes */
  --track: #F0E9DB;
  --accent: #B33A1E;        /* vermilion */
  --accent-deep: #7E2711;
  --accent-wash: #F3E2DC;
  --accent-line: #C98A76;
  --amber: #DFA84E;         /* lamplight: the clock is running */
  --danger: #8C1D12;
  --warn-wash: #F7E7C6;
  --warn-line: #DFA84E;
  --radius: 12px;
  --radius-s: 7px;
  --shadow: 0 2px 8px rgba(25, 22, 19, 0.06);
  --font: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Source Serif 4', Georgia, 'Times New Roman', serif;   /* the name, headings, the journal's writing */
  --data: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;   /* labels and figures */
  --motto: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --tabs-h: 58px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: rgba(25, 22, 19, 0.25) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--accent);
}
::selection { background: #EFD9B4; color: var(--ink); }

h1, h2, h3, h4, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
/* panel labels: small, uppercase, vermilion */
h2 { font-family: var(--data); font-size: 12px; line-height: 1.4; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; color: var(--accent); }
h3 { font-family: var(--display); font-size: 22px; line-height: 1.2; font-weight: 500; text-wrap: balance; }
h4 { font-family: var(--data); font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
h3[tabindex="-1"]:focus { outline: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--data); font-variant-numeric: tabular-nums; }
.narrow-only { display: none; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- frame */

.top { border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-in {
  max-width: 1160px; margin: 0 auto; min-height: 58px;
  padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { flex: none; font-family: var(--display); font-size: 24px; line-height: 1.2; font-weight: 600; color: var(--accent); }
.top-nav { flex: none; display: flex; gap: 2px; }
.top-nav a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 4px 12px;
  font-family: var(--data); font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
  transition: color 0.15s;
}
.top-nav a:hover { color: var(--ink); }
.top-nav a[aria-current] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.motto {
  flex: 1; min-width: 0; padding: 0 12px; text-align: center;
  font-family: var(--motto); font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.motto i { font-style: normal; color: var(--accent); padding: 0 6px; }
.top-right { flex: none; display: flex; align-items: center; gap: 20px; font-size: 13px; }
.top-date { color: var(--muted); }
.top-link { color: var(--accent); background: none; border: 0; padding: 6px 0; font-weight: 600; text-decoration: none; }
.top-link:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 1180px) { .motto { display: none; } }

.net { background: var(--warn-wash); border-bottom: 1px solid var(--warn-line); text-align: center; font-size: 13px; padding: 8px 16px; }

.wrap {
  max-width: 1160px; margin: 0 auto;
  padding: 18px max(22px, env(safe-area-inset-right)) 56px max(22px, env(safe-area-inset-left));
}
.view-log { display: grid; gap: 26px; }
.today-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }

.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px 18px; min-width: 0; }
.panel-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; margin-bottom: 12px; }
.section-head { margin-bottom: 8px; padding: 0 2px; }
.empty { max-width: 46ch; color: var(--muted); line-height: 1.6; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.row.end { justify-content: flex-end; }

.label { display: block; font-family: var(--data); font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.tag { display: inline-block; font-family: var(--data); font-size: 12px; line-height: 1.45; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 7px; white-space: nowrap; }
.tag-today { color: var(--accent); border-color: var(--accent-line); }

.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; text-decoration: none; }
.link:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
.foot { display: flex; justify-content: center; gap: 24px; font-size: 13px; }
.foot .link { padding: 10px 4px; }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--well); color: var(--ink);
  font-size: 14px; font-weight: 700; line-height: 1.2; text-align: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { background: var(--line-soft); }
.btn:disabled { color: var(--disabled); background: transparent; border-color: var(--line-soft); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); letter-spacing: 1px; text-transform: uppercase; }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn-primary:active:not(:disabled) { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-primary:disabled { background: var(--line); border-color: var(--line); color: var(--ink-soft); }
.btn-wide { width: 100%; min-height: 46px; }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-small.btn-primary { letter-spacing: 0.6px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn-quiet:hover:not(:disabled) { border-color: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-danger.armed, .btn-danger.armed:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border: 0; border-radius: var(--radius-s); background: transparent; color: var(--muted); transition: background-color 0.15s, color 0.15s; }
.icon-btn:hover:not(:disabled) { background: var(--well); color: var(--ink); }
.icon-btn.bordered { border: 1px solid var(--line); color: var(--ink); }
.icon-btn.bordered:hover:not(:disabled) { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.icon-btn:disabled { color: var(--disabled); border-color: var(--line-soft); }

.field {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--edge); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font-size: 16px;
  transition: border-color 0.15s;
}
.field::placeholder { color: var(--hint); }
.field:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }

.segment { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segment-btn { min-height: 36px; padding: 8px 16px; border: 0; background: transparent; color: var(--muted); font-family: var(--data); font-size: 12px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; }
.segment-btn + .segment-btn { border-left: 1px solid var(--line); }
.segment-btn:hover { color: var(--ink); }
.segment-btn.on { background: var(--ink); color: var(--bg); }
.segment-btn:focus-visible { outline-offset: -3px; }

.banner { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--warn-line); border-radius: var(--radius-s); background: var(--warn-wash); font-size: 14px; line-height: 1.5; }
.banner-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.banner-row .field { width: auto; flex: 1 1 200px; }

.row-error { color: var(--accent-deep); font-size: 13px; font-weight: 500; padding: 8px 10px; background: var(--accent-wash); border: 1px solid var(--accent-line); border-radius: var(--radius-s); }

/* ---------------------------------------------------------------- dialog, toast, tooltip */

dialog.dialog {
  width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 60px -12px rgba(25, 22, 19, 0.3);
}
dialog.dialog[open] { display: flex; flex-direction: column; }
dialog.dialog::backdrop { background: rgba(25, 22, 19, 0.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 10px 10px 20px; border-bottom: 1px solid var(--line-soft); }
.dialog-body { padding: 18px 20px 20px; overflow: hidden auto; overscroll-behavior: contain; display: grid; gap: 14px; align-content: start; }
.dialog-body h3 { font-family: var(--data); font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent); margin-top: 8px; }
.dialog-body .label { margin-bottom: -8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  max-width: min(520px, calc(100vw - 32px)); width: max-content;
  padding: 10px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--bg); font-size: 14px; text-align: center;
  box-shadow: 0 10px 28px -8px rgba(25, 22, 19, 0.4);
}
.tip {
  position: fixed; z-index: 70; pointer-events: none; max-width: 260px;
  padding: 7px 10px; border-radius: 6px;
  background: var(--ink); color: var(--bg); font-size: 13px; line-height: 1.45; font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 20px -8px rgba(25, 22, 19, 0.4);
}
.tip-title { font-weight: 700; }

/* ---------------------------------------------------------------- turning between Log and Notes */

.screen-leaf { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; overflow: hidden; background: var(--bg); will-change: transform; }
.screen-copy { position: absolute; margin: 0; pointer-events: none; }
.screen-shade { position: absolute; inset: 0; background: var(--ink); opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- phone tabs */

.tabs { display: none; }
.noscript { padding: 24px; text-align: center; }

@media (max-width: 899.98px) {
  .wide-only { display: none !important; }
  .narrow-only { display: block; }
  body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
  .top-in { min-height: 52px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .wrap { padding: 14px max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left)); }
  .view-log { gap: 14px; }
  .today-view { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs button { flex: 1; height: var(--tabs-h); border: 0; background: transparent; color: var(--muted); font-family: var(--data); font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
  .tabs button[aria-current] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
  .tabs button:focus-visible { outline-offset: -4px; }
  body[data-tab="today"] .book { display: none; }
  body[data-tab="journal"] .today-view { display: none; }
  .toast { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); }
  .btn { min-height: 44px; }
  .btn-small { min-height: 44px; }
  .segment-btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .field { min-height: 44px; }
}

/* ---------------------------------------------------------------- login page */

.login-body { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login { width: min(380px, 100%); }
.login h1 { font-family: var(--display); font-size: 36px; line-height: 1.15; font-weight: 600; color: var(--accent); }
.login-motto { margin-top: 10px; font-family: var(--motto); font-size: 13px; line-height: 1.7; letter-spacing: 1.6px; text-transform: uppercase; text-wrap: balance; }
.login-form { margin-top: 26px; padding: 20px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 8px; }
.login-form .btn { margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* the motto sits in the header on wide screens, so the journal's own copy steps aside there */
@media (min-width: 1180.02px) { .summary-page .motto-line { display: none; } }
