/* Design tokens and shared styles. Component styles live next to each component. */

:root {
  color-scheme: light;

  /* Walnut & Mustard: an Eames living room. Cream walls, walnut wood, mustard and
     burnt-orange cushions, a touch of teal. */
  --bg: #f3ebdd;
  --bg-2: #fbf7ef;
  --surface: #fbf6ec;
  --surface-2: #f1e6d3;
  --surface-3: #e7d8bf;
  --line: rgb(107 66 38 / 0.14);
  --line-strong: rgb(107 66 38 / 0.26);
  --text: #3a2a1d;
  --muted: #76634e;
  --faint: #a08c73;

  --walnut: #6b4226;
  --walnut-ink: #fbf3e4;
  --mustard: #d9a21b;
  --mustard-deep: #8a5a12;
  --rust: #c8552b;
  --teal: #2e6e6a;
  --avocado: #7f8f33;
  --sky: #4f7a9a;

  /* The names that the components use. */
  --accent: var(--mustard);
  --accent-ink: var(--text);
  --green: var(--teal);
  --green-ink: #fbf6ec;
  --orange: var(--rust);
  --purple: var(--walnut);
  --pink: #b9654d;
  --blue: var(--sky);
  --yellow: #a8740c;
  --danger: #b5402a;

  --font-display: "Jost", "Heebo", system-ui, sans-serif;
  --font-body: "Karla", "Heebo", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.7) inset, 0 12px 26px -16px rgb(107 66 38 / 0.45);
  --glow: 0 0 0 3px rgb(217 162 27 / 0.32);

  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; line-height: 1.15; }
h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }

::selection { background: rgb(217 162 27 / 0.35); }

:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; border-radius: 6px; }

/* ---------- Shared building blocks ---------- */

.eyebrow {
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rust);
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--font-mono); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font: 700 14px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { box-shadow: var(--glow); background: #e3ad25; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 40px; padding: 0; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font: 500 12px/1 var(--font-body);
  white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--text);
  font: 15px/1.3 var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--mustard); box-shadow: 0 0 0 3px rgb(217 162 27 / 0.22); }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--green); }
input[type="color"] { padding: 4px; }

/* ---------- Dialogs ---------- */

dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 32px 80px -20px rgb(58 42 29 / 0.45);
}
dialog::backdrop { background: rgb(58 42 29 / 0.32); backdrop-filter: blur(4px); }
dialog[open] { animation: pop 0.18s ease-out; }
dialog form { display: grid; gap: 16px; padding: 24px; }
dialog .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
dialog .dialog-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
dialog .dialog-foot .spacer { flex: 1; }

@media (max-width: 600px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  dialog[open] { animation: slide-up 0.22s ease-out; }
}

@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.enter { animation: fade-in 0.3s ease-out both; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--walnut);
  color: var(--walnut-ink);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-weight: 500;
  animation: fade-in 0.2s ease-out;
}
.toast.error { background: var(--danger); border-color: var(--danger); }

/* Fingers need bigger targets than a mouse. On touch screens, small controls grow
   (or get a bigger invisible hit area) to at least 32 px. */
@media (pointer: coarse) {
  .chip { height: 34px; padding: 0 12px; }
  .btn.sm { min-height: 38px; }
  .task-row .tick { position: relative; }
  .task-row .tick::after { content: ""; position: absolute; inset: -10px; }
  recording-detail button.t { height: 28px; padding: 0 9px; font-size: 12px; }
  campus-map .panel button.handle { height: 30px; }
}

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