/* The look of every page of ours: warm, quiet, and the same on each. The pages differ
   only in what they add (admin.css). Colours are set once, here, for light and for dark;
   theme.js puts data-theme on <html> when a person has chosen, and without it the
   device's own setting decides. */

:root {
  color-scheme: light;
  --fg: #2b211b; --muted: #74655a; --line: #eadfd3; --bg: #fbf6ef; --bg-2: #f4e9dc;
  --card: #fffdf9; --accent: #b4532a; --accent-soft: #f7dfcf; --new: #fdefc9;
  --bad: #b3261e; --glow-1: rgba(232, 164, 110, 0.20); --glow-2: rgba(214, 181, 129, 0.18);
  --shadow: 0 1px 2px rgba(74, 48, 28, 0.06), 0 6px 18px rgba(74, 48, 28, 0.06);
  --ease: 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fg: #f3ebe2; --muted: #b6a696; --line: #453a31; --bg: #1d1814; --bg-2: #251e19;
  --card: #2a221c; --accent: #f0a877; --accent-soft: #4a2f1f; --new: #4a3a1c;
  --bad: #ffb4a8; --glow-1: rgba(214, 120, 62, 0.16); --glow-2: rgba(160, 120, 70, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 22px rgba(0, 0, 0, 0.28);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fg: #f3ebe2; --muted: #b6a696; --line: #453a31; --bg: #1d1814; --bg-2: #251e19;
    --card: #2a221c; --accent: #f0a877; --accent-soft: #4a2f1f; --new: #4a3a1c;
    --bad: #ffb4a8; --glow-1: rgba(214, 120, 62, 0.16); --glow-2: rgba(160, 120, 70, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 22px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--fg);
  font: 16px/1.55 "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  /* two soft lights on a warm ground; it stays put while the page scrolls */
  background:
    radial-gradient(60rem 34rem at 8% -8%, var(--glow-1), transparent 70%),
    radial-gradient(48rem 30rem at 104% 4%, var(--glow-2), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
  background-attachment: fixed;
}
html.ready body, html.ready header, html.ready button, html.ready input, html.ready select,
html.ready table, html.ready th, html.ready td, html.ready .card, html.ready .tile, html.ready #notice {
  transition: background-color var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

/* The bar of pages down the left, and the page beside it. */
body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; }
#nav { position: sticky; top: 0; height: 100vh; width: 14.5rem; padding: 0.8rem 0.6rem; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--card) 72%, transparent); backdrop-filter: blur(6px); overflow: hidden; transition: width 240ms cubic-bezier(0.2, 0.7, 0.2, 1); }
html[data-nav="closed"] #nav { width: 3.6rem; }
#nav-toggle { display: grid; gap: 4px; width: 2.4rem; height: 2.4rem; padding: 0.6rem 0.55rem; border-radius: 10px; align-content: center; }
#nav-toggle span { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: transform var(--ease), opacity var(--ease); }
html[data-nav="open"] #nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
html[data-nav="open"] #nav-toggle span:nth-child(2) { opacity: 0; }
html[data-nav="open"] #nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
#nav-pages { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.3rem; }
#nav-pages a { overflow: hidden; display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem; border-radius: 12px; border: 1px solid transparent; color: var(--fg); text-decoration: none; white-space: nowrap; transition: background-color var(--ease), border-color var(--ease), color var(--ease); }
#nav-pages a:hover { background: var(--accent-soft); }
#nav-pages a[aria-current="page"] { background: var(--card); border-color: var(--accent); box-shadow: var(--shadow); }
#nav-pages .initial { flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 8px; background: var(--bg-2); color: var(--muted); font: 600 0.95rem/1 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
#nav-pages a[aria-current="page"] .initial { background: var(--accent); color: var(--card); }
#nav-pages .words { min-width: 0; display: grid; line-height: 1.25; transition: opacity var(--ease); }
#nav-pages small { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; }
html[data-nav="closed"] #nav-pages .words { opacity: 0; }
#page { min-width: 0; }
@media (max-width: 40rem) {
  #nav { width: 3.6rem; }
  html[data-nav="open"] #nav { position: fixed; z-index: 3; width: 14.5rem; background: var(--card); box-shadow: var(--shadow); }
  html[data-nav="open"] #page { margin-left: 3.6rem; }
}

header, main { max-width: 60rem; margin: 0 auto; padding: 1rem 1.25rem; }
header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; border-bottom: 1px solid var(--line); }
header > div { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; }
h1 { font: 600 1.45rem/1.2 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; letter-spacing: 0.01em; margin: 0; }
h1 .muted { font-family: inherit; font-style: italic; color: var(--accent); }
.muted { color: var(--muted); font-weight: normal; }
a { color: var(--accent); text-underline-offset: 0.18em; }

button, select, input { font: inherit; color: inherit; }
input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; }
button { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0.32rem 0.95rem; cursor: pointer; box-shadow: 0 1px 1px rgba(74, 48, 28, 0.05); }
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.5; cursor: default; }
#theme { font-size: 0.85rem; color: var(--muted); padding: 0.22rem 0.75rem; }
select, input[type="datetime-local"], input[type="text"], input[type="email"] { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.28rem 0.5rem; }
#sign-in { font-size: 1.1rem; padding: 0.55rem 1.6rem; background: var(--accent); border-color: var(--accent); color: var(--card); box-shadow: var(--shadow); }
#sign-in:hover { color: var(--card); filter: brightness(1.06); }

#signed-out, #not-admin, #factor { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.2rem 1.5rem; margin-top: 1.5rem; max-width: 40rem; }
#notice { background: var(--card); border: 1px solid var(--accent); border-left-width: 4px; border-radius: 10px; padding: 0.6rem 0.9rem; box-shadow: var(--shadow); }
#idle-warning { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; position: sticky; top: 0.5rem; z-index: 1; background: var(--new); border: 1px solid var(--accent); border-radius: 12px; padding: 0.6rem 0.9rem; margin-bottom: 0.8rem; box-shadow: var(--shadow); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem; margin: 0.4rem 0 0.8rem; }
.tabs, .presets { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
.check { color: var(--muted); }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
th, td { text-align: left; vertical-align: top; padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.02em; background: var(--bg-2); }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
td.when, td.value { font-family: ui-monospace, Menlo, monospace; font-size: 0.88rem; white-space: nowrap; }
td.value { white-space: normal; overflow-wrap: anywhere; }
td.note { color: var(--muted); font-size: 0.88rem; }
tr.on td.value { color: var(--accent); font-weight: 600; }
tr.fresh td { background: var(--new); }
tr.quiet { color: var(--muted); }
body.hide-quiet tr.quiet { display: none; }

/* What appears, arrives: a short rise, never a jump. */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
main > section:not([hidden]), [role="tabpanel"]:not([hidden]), #notice:not([hidden]), #idle-warning:not([hidden]) { animation: rise 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
tr.fresh { animation: rise 320ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  button:hover:not(:disabled) { transform: none; }
}
