/* ==========================================================================
   Golten Stories — app styles (playful / light)
   --------------------------------------------------------------------------
   Ported from the design system in design/kokosbananas.css. Top half is the
   system (tokens + shared components); bottom half is the audio-lab-specific
   components (renditions, players, spectrograms, forms) restyled to the tokens.
   ========================================================================== */

/* 1. TOKENS ================================================================ */
:root {
  --banana:  #ffd23f; --banana-deep: #f4b400;
  --coconut: #7b4b2a; --cream:   #fff6e9;
  --leaf:    #2fae5f; --sky:     #19a7b5;
  --coral:   #ff6b6b; --grape:   #8a6fe8; --bubble: #ff8fab;

  --bg: #ffffff; --surface: #fffdf8; --surface-2: var(--cream);
  --ink: #2a2018; --muted: #8a7e72; --line: #efe6d8;

  --font-display: "National Park", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font-body:    "Nunito", ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  --fs-xs: .78rem; --fs-sm: .9rem; --fs-md: 1rem; --fs-lg: 1.2rem;
  --fs-xl: 1.6rem; --fs-2xl: 2.2rem; --fs-3xl: clamp(2rem, 5vw, 3.4rem);

  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem;
  --s5: 1.5rem; --s6: 2rem; --s7: 3rem; --s8: 4rem;

  --r-sm: 10px; --r: 16px; --r-lg: 24px; --r-pill: 999px;
  --shadow-soft: 0 10px 30px -12px rgba(123, 75, 42, .25);
}

/* 2. BASE ================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: var(--fs-md); line-height: 1.6;
  color: var(--ink); background-color: var(--bg);
  background-image:
    radial-gradient(40rem 40rem at 110% -10%, rgba(255, 210, 63, .18), transparent 60%),
    radial-gradient(34rem 34rem at -10% 110%, rgba(25, 167, 181, .14), transparent 60%);
  background-attachment: fixed;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.1; margin: 0 0 var(--s3); color: var(--ink); }
h1 { font-size: var(--fs-3xl); letter-spacing: -.01em; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--s4); }
a { color: var(--sky); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
small { font-size: var(--fs-xs); }
.muted { color: var(--muted); }

/* 3. LAYOUT ================================================================ */
.wrap { max-width: 1040px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s8); }
.wrap > section { margin: 0 0 var(--s7); }
.eyebrow, .kicker { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .12em;
  font-size: var(--fs-xs); color: var(--coconut); margin: 0 0 var(--s2); }
.grid { display: grid; gap: var(--s4); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }

/* 4. SHARED COMPONENTS ===================================================== */

/* Brand + top bar */
.brand { display: inline-flex; align-items: center; gap: var(--s2); font-family: var(--font-display);
  font-weight: 600; font-size: var(--fs-lg); color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.topbar {
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s3) var(--s5); background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(8px); border-bottom: 2px dashed var(--line); position: sticky; top: 0; z-index: 10;
}
.topnav { margin-left: auto; display: flex; gap: var(--s4); }
.topnav a { color: var(--coconut); }

/* Buttons — rounded, chunky, press DOWN (never lift) */
.btn {
  --chunk: var(--banana-deep);
  display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md);
  padding: var(--s3) var(--s5); border: 0; border-radius: var(--r-pill);
  background: var(--banana); color: var(--ink); box-shadow: 0 4px 0 0 var(--chunk);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease; text-decoration: none;
}
.btn:hover { filter: brightness(1.03); text-decoration: none; transform: translateY(2px); box-shadow: 0 2px 0 0 var(--chunk); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 0 var(--chunk); }
.btn--leaf  { --chunk: #1f8f4a; background: var(--leaf);  color: #fff; }
.btn--sky   { --chunk: #11808c; background: var(--sky);   color: #fff; }
.btn--coral { --chunk: #e24e4e; background: var(--coral); color: #fff; }
.btn--ghost { background: #fff; color: var(--ink); box-shadow: none; border: 2px solid var(--line); }
.btn--ghost:hover { transform: none; box-shadow: none; border-color: var(--banana-deep); }
.btn--sm { padding: var(--s2) var(--s4); font-size: var(--fs-sm); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: .2em .7em; border-radius: var(--r-pill); font-weight: 700; font-size: var(--fs-xs);
  font-family: var(--font-body); background: var(--cream); color: var(--coconut); white-space: nowrap;
}
.chip--banana { background: #fff1c2; color: #8a6a00; }
.chip--leaf   { background: #d4f4df; color: #1f7a45; }
.chip--sky    { background: #cdeef2; color: #0f6b76; }
.chip--coral  { background: #ffe0e0; color: #c43c3c; }
.chip--grape  { background: #e9e2fb; color: #5b46b0; }
.chip--live::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 0 rgba(47,174,95,.6); animation: pulse 1.8s infinite; }

/* Cards + the pale accent WASH (shared by cards & callouts) */
.card { --accent: var(--banana); background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-soft); }
.card h3 { margin-top: 0; }
.card--wash, .callout {
  --accent: var(--banana); border: 0; border-color: transparent;
  background: color-mix(in srgb, var(--accent) 14%, #fff);
  box-shadow: 0 10px 24px -16px color-mix(in srgb, var(--accent) 70%, #000);
}

/* Hero */
.hero { padding: var(--s7) 0 var(--s6); }
.hero h1 { max-width: 18ch; }
.hero .lede { font-size: var(--fs-lg); max-width: 56ch; color: var(--muted); }
.takeaway { margin-top: var(--s5); background: color-mix(in srgb, var(--cream) 70%, #fff);
  border: 2px dashed var(--line); border-radius: var(--r); padding: var(--s4) var(--s5); color: var(--ink); }

/* Forms */
label { display: inline-flex; flex-direction: column; gap: var(--s1); font-weight: 700; font-size: var(--fs-sm); color: var(--coconut); }
input[type=file], input[type=number], input[type=text], select, textarea {
  font: inherit; padding: var(--s2) var(--s3); border: 2px solid var(--line);
  border-radius: var(--r-sm); background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(25,167,181,.35); border-color: var(--sky); }
.check { flex-direction: row; align-items: center; gap: var(--s2); }
input[type=checkbox] { width: 1.2em; height: 1.2em; accent-color: var(--leaf); }
label small { font-weight: 400; color: var(--muted); }

/* Selects — custom caret so they don't fall back to the native control */
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: calc(var(--s5) + var(--s3));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%237b4b2a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s3) center; background-size: .7rem;
}

/* File input — dress the native "choose file" button as a design-system pill */
input[type=file] { cursor: pointer; line-height: 1.5; }
input[type=file]::file-selector-button {
  font: inherit; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm);
  margin: 0 var(--s3) 0 0; padding: var(--s2) var(--s4);
  border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: var(--cream); color: var(--coconut);
  transition: background .15s ease, color .15s ease;
}
input[type=file]::file-selector-button:hover { background: var(--banana); color: var(--ink); }

/* Field + trailing unit (e.g. LUFS, dBTP) stay on one line */
.field-unit { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 700; color: var(--coconut); }

/* Callout (layout only; wash comes from the shared rule) */
.callout { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4) var(--s5); border-radius: var(--r); }

/* Tables */
.table-wrap { border: 2px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.table-wrap--scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: var(--s3) var(--s4); text-align: left; white-space: nowrap; }
.table thead th { background: var(--cream); color: var(--coconut); font-family: var(--font-display);
  font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }
.table tbody td { border-top: 1px solid var(--line); }
.table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--cream) 45%, #fff); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .warn { color: var(--coral); font-weight: 800; }

/* Timeline (roadmap) */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 var(--s6) var(--s6); }
/* connector: runs from this dot down to the next one */
.timeline li::before { content: ""; position: absolute; left: 5px; top: calc(.5rem + 6px);
  width: 2px; height: 100%; background: var(--line); }
.timeline li:last-child::before { display: none; }
/* state dot */
.timeline li::after { content: ""; position: absolute; left: 0; top: .5rem;
  width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;
  background: #fff; border: 2px solid var(--line); }
.timeline h3 { display: flex; align-items: center; gap: var(--s2); }
/* states: done = filled, current = pulsing, in-progress = amber, upcoming = hollow + dimmed */
.timeline .is-done::after       { background: var(--leaf); border-color: var(--leaf); }
.timeline .is-done::before      { background: var(--leaf); }
.timeline .is-current::after    { background: var(--leaf); border-color: var(--leaf);
  animation: pulse 1.8s infinite; }
.timeline .is-inprogress::after { background: var(--banana-deep); border-color: var(--banana-deep); }
.timeline .is-inprogress h3     { color: var(--ink); }
.timeline .is-upcoming h3       { color: var(--muted); }

/* Footer */
.foot { border-top: 2px dashed var(--line); padding: var(--s5); text-align: center; color: var(--muted); }

/* 5. AUDIO-LAB COMPONENTS ================================================== */
.crumb { font-size: var(--fs-sm); margin: 0 0 var(--s3); }
.detailhead .btn { margin-top: var(--s3); }

/* Upload + tweak forms sit in card-like panels */
.uploadform, .tweakform {
  display: flex; gap: var(--s4); flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg); padding: var(--s5);
}
.uploadform { align-items: center; }
.uploadform input[type=file] { flex: 1 1 280px; }
.spinner { color: var(--coconut); font-weight: 700; font-size: var(--fs-sm); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* Recent-uploads list */
.uploads { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.uploads li { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); }
.uploads li > a { font-weight: 800; }
.uploads li .btn { margin-left: auto; }

/* Renditions grid: master is a neutral card, emulations get a platform wash */
.renditions { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--s4); margin-top: var(--s4); }
.renditions .card { display: flex; flex-direction: column; gap: var(--s3); }
.rend-selfhosted { --accent: var(--banana); }
.rend-spotify    { --accent: var(--leaf); }
.rend-youtube    { --accent: var(--coral); }
.settings { font-size: var(--fs-sm); color: var(--coconut); font-weight: 700; margin: 0; }
.note { font-size: var(--fs-sm); color: var(--muted); margin: 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s4); margin: 0; }
.stats > div { display: flex; flex-direction: column; }
.stats dt { font-family: var(--font-display); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--coconut); margin: 0; }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; }
.stats dd.warn { color: var(--coral); }

audio.abplayer { width: 100%; margin-top: var(--s1); }
.spectro-fig { margin: 0; }
.spectro-fig figcaption { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--s1); }
.spectro { width: 100%; display: block; border-radius: var(--r-sm); background: #000; cursor: zoom-in; border: 2px solid var(--line); }
.dl { font-size: var(--fs-sm); }

/* Findings disclosure */
.findings { margin-top: var(--s6); background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s5); }
.findings summary { cursor: pointer; font-weight: 700; font-family: var(--font-display); color: var(--ink); }
.findings ul { margin: var(--s3) 0; padding-left: 1.1rem; }
.findings li { margin: var(--s2) 0; }

/* 6. KATALOG OVERVIEW PAGE ================================================= */
/* Entity reference list */
.entity-list { display: flex; flex-direction: column; gap: var(--s2); }
.entity-row { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); }
.entity-header { display: flex; align-items: center; gap: var(--s3); }
.entity-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.entity-type { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); }
.entity-fields { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s4);
  padding-left: calc(14px + var(--s3)); font-size: var(--fs-sm); margin-top: var(--s2); }
.entity-fields dt { color: var(--muted); white-space: nowrap; }
.entity-fields dd { margin: 0; word-break: break-word; }
/* Catalog tree (program -> file) */
.tree { display: flex; flex-direction: column; gap: var(--s2); }
.tree-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); border-radius: var(--r); background: var(--surface); }
.tree .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.ttype { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-size: var(--fs-xs); color: var(--muted); min-width: 6ch; }
.tname { font-weight: 700; }
.tdetail { color: var(--muted); font-size: var(--fs-sm); margin-left: auto; }
.tchips { margin-left: auto; display: flex; gap: var(--s1); flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* 7. MOTION ================================================================ */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,174,95,.6); } 70% { box-shadow: 0 0 0 .5em rgba(47,174,95,0); } 100% { box-shadow: 0 0 0 0 rgba(47,174,95,0); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
