/* Borderlands Soundboard. Built on the platform conventions people already know: a navigation bar with a back
   button and a large title, inset grouped lists, segmented controls, a Now Playing bar and sheets. Content first;
   the chrome is translucent and gets out of the way. Light and dark appearance both follow the system. */
:root {
  color-scheme: dark;
  --bg: #141210; --bg-elev: #1d1a16; --card: #24201b; --card-press: #2e2922;
  --fill: rgba(120, 112, 100, 0.24); --fill-strong: rgba(150, 140, 125, 0.32); --sep: rgba(255, 245, 225, 0.09);
  --label: #f4eee3; --label-2: rgba(244, 238, 227, 0.62); --label-3: rgba(244, 238, 227, 0.36);
  --material: rgba(26, 23, 19, 0.72); --seg-on: #5b544b; --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --accent: #e2a64c; --on-accent: #1d1406;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, 'Segoe UI', Roboto, sans-serif;
  --r: 12px; --sidebar: 288px; --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f2ed; --bg-elev: #ffffff; --card: #ffffff; --card-press: #ece7df;
    --fill: rgba(118, 108, 96, 0.14); --fill-strong: rgba(118, 108, 96, 0.22); --sep: rgba(40, 30, 15, 0.12);
    --label: #1d1a16; --label-2: rgba(29, 26, 22, 0.6); --label-3: rgba(29, 26, 22, 0.34);
    --material: rgba(247, 244, 239, 0.78); --seg-on: #ffffff; --shadow: 0 8px 30px rgba(60, 40, 10, 0.16);
    --accent: #b8741a; --on-accent: #fff;
  }
}
/* each part of the map has its own tint */
body[data-region="wilderness"] { --accent: #79bf72; --on-accent: #0c1a0a; }
body[data-region="caves"] { --accent: #f06a52; --on-accent: #1f0804; }
body[data-place^="cave-k"], body[data-place="ritual"] { --accent: #b18cf2; --on-accent: #160b26; }
body[data-place="fens"], body[data-place="lizard-camp"], body[data-place="stirges"] { --accent: #5cc4b0; --on-accent: #06201b; }
@media (prefers-color-scheme: light) {
  body[data-region="wilderness"] { --accent: #3f8a39; --on-accent: #fff; }
  body[data-region="caves"] { --accent: #c9432c; --on-accent: #fff; }
  body[data-place^="cave-k"], body[data-place="ritual"] { --accent: #7a4fc4; --on-accent: #fff; }
  body[data-place="fens"], body[data-place="lizard-camp"], body[data-place="stirges"] { --accent: #23877a; --on-accent: #fff; }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--label); font: 17px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---- navigation bar */
.app { min-height: 100vh; }
.navbar {
  position: sticky; top: 0; z-index: 20; height: 52px; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: var(--material); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid transparent; transition: border-color 0.2s;
}
body.scrolled .navbar { border-bottom-color: var(--sep); }
.nav-back { justify-self: start; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px; color: var(--accent); font-size: 17px; max-width: 42vw; }
.nav-back span:first-child { font-size: 30px; line-height: 1; margin-top: -3px; }
.nav-back #back-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-title { margin: 0; font-weight: 600; font-size: 17px; opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
body.scrolled .nav-title { opacity: 1; transform: none; }
.nav-btn { justify-self: end; min-height: 44px; padding: 0 8px; color: var(--accent); font-size: 17px; }

/* ---- content */
.content { max-width: 780px; margin: 0 auto; padding: 4px max(20px, env(safe-area-inset-left)) 150px; }
.hero { padding: 8px 0 22px; }
.kicker { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: 0.01em; }
.hero h1 { margin: 0; font: 700 34px/1.12 var(--display); letter-spacing: 0.01em; text-wrap: balance; }
.subtitle { margin: 8px 0 0; font-size: 17px; color: var(--label-2); max-width: 60ch; text-wrap: pretty; }

.group { margin-bottom: 30px; }
.group-label { margin: 0 0 7px 16px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.02em; color: var(--label-2); }

/* inset grouped list */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--r); overflow: hidden; }
.list li + li .list-row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.list li:has(.badge) + li .list-row::before { left: 56px; }
.list-row { position: relative; width: 100%; min-height: 60px; display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 16px; text-align: left; transition: background 0.15s; }
.list-row:active { background: var(--card-press); }
@media (hover: hover) { .list-row:hover { background: color-mix(in srgb, var(--card-press) 60%, var(--card)); } }
.badge { flex: none; width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-size: 17px; font-weight: 500; }
.row-sub { font-size: 14px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { flex: none; font-size: 13px; color: var(--label-3); white-space: nowrap; }
.chev { flex: none; font-size: 22px; line-height: 1; color: var(--label-3); margin-top: -2px; }
@media (max-width: 640px) { .row-meta { display: none; } }

/* segmented control */
.segmented { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented button { flex: 1 1 auto; min-width: 0; min-height: 32px; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--label); white-space: nowrap; transition: background 0.2s var(--ease), box-shadow 0.2s; }
.segmented [aria-selected="true"], .segmented [aria-checked="true"] { background: var(--seg-on); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
#tabs { margin-bottom: 12px; }
@media (max-width: 380px) { .segmented button { font-size: 12px; padding: 0 3px; } }

/* sound pads */
.pads { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pad {
  position: relative; overflow: hidden; min-height: 78px; padding: 12px 14px; border-radius: 14px; background: var(--card);
  display: flex; align-items: flex-end; text-align: left; font-size: 15px; font-weight: 600; line-height: 1.25;
  transition: transform 0.25s var(--ease), background 0.2s; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.pad span { position: relative; z-index: 1; }
.pad:active { transform: scale(0.96); background: var(--card-press); transition-duration: 0.08s; }
.pad kbd { position: absolute; top: 9px; right: 11px; font: 600 11px/1 var(--font); color: var(--label-3); }
@media (hover: none) { .pad kbd { display: none; } }
.pad--cue { background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
/* while a sound plays, its pad glows and fills along the bottom */
.pad::before { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 22%, transparent); opacity: 0; }
.pad::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.pad.hit::before { animation: glow var(--dur, 1s) ease-out; }
.pad.hit::after { animation: fill var(--dur, 1s) linear; }
@keyframes glow { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fill { 0% { transform: scaleX(0); opacity: 1; } 99% { transform: scaleX(1); opacity: 1; } 100% { opacity: 0; } }

/* ---- now playing */
.player {
  position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--material); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-top: 0.5px solid var(--sep);
}
.play { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); transition: transform 0.2s var(--ease); }
.play:active { transform: scale(0.92); }
.play svg { width: 22px; height: 22px; fill: currentColor; }
.play .i-pause, body.playing .play .i-play { display: none; }
body.playing .play .i-pause { display: inline; }
.now { min-width: 0; }
.now-title { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-sub { margin: 1px 0 0; font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moods { min-width: 320px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); }
.icon-btn:active { background: var(--fill); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (max-width: 720px) {
  .player { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 10px; }
  .moods { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .content { padding-bottom: 190px; }
}

/* ---- sidebar map: always there on a wide screen, slides over on a small one */
.sidebar {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: var(--sidebar); overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 10px calc(100px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: var(--bg-elev); border-right: 0.5px solid var(--sep);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 6px; }
.home { color: var(--accent); text-decoration: none; font-size: 15px; }
.sidebar-title { display: block; margin: 6px 0 10px; padding: 4px 8px; border-radius: 8px; text-align: left; font: 700 22px/1.2 var(--display); }
.sidebar-title.is-here { color: var(--accent); }
.map-search { display: block; width: 100%; margin: 0 0 12px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--fill); color: var(--label); font: 16px/1.2 var(--font); }
.map-search::placeholder { color: var(--label-3); }
.map-group { margin: 14px 0 4px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--label-2); }
.map-row .map-where { display: block; font-size: 12px; color: var(--label-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-row.is-here .map-where { color: inherit; opacity: 0.75; }
.map-row .map-text { flex: 1; min-width: 0; }
.map-empty { margin: 16px 10px; color: var(--label-2); font-size: 15px; }
.map-list, .map-list ul { list-style: none; margin: 0; padding: 0; }
.map-row {
  width: 100%; min-height: 34px; display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-radius: 8px; text-align: left; font-size: 15px; color: var(--label);
}
.map-list > li { margin-bottom: 2px; }
.map-row.d0 { font-weight: 600; min-height: 40px; }
.map-list > li + li { border-top: 0.5px solid var(--sep); padding-top: 2px; }
.map-row.d2 { padding-left: 24px; }
.map-row.d3 { padding-left: 38px; }
@media (hover: hover) { .map-row:hover { background: var(--fill); } }
.map-row.is-here { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.map-row.is-here .chev { color: inherit; }
.map-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row .chev { font-size: 16px; transition: transform 0.2s var(--ease); }
.map-row .chev.open { transform: rotate(90deg); }
.close-map { display: none; width: 36px; height: 36px; font-size: 15px; background: var(--fill); color: var(--label-2); }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.36); }

@media (min-width: 1100px) {
  .app { margin-left: var(--sidebar); }
  .player { left: var(--sidebar); }
  .nav-btn { visibility: hidden; }
  .scrim { display: none; }
}
@media (max-width: 1099px) {
  .sidebar { width: min(320px, 86vw); transform: translateX(-105%); transition: transform 0.35s var(--ease); box-shadow: var(--shadow); }
  body.map-open .sidebar { transform: none; }
  .close-map { display: grid; }
}

/* ---- sheets */
.sheet {
  width: min(540px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 64px)); padding: 0; border: 0; border-radius: 14px;
  background: var(--bg); color: var(--label); box-shadow: var(--shadow); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: rise 0.35s var(--ease); }
.sheet::backdrop { background: rgba(0, 0, 0, 0.36); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 56px; padding: 0 8px; }
.sheet-head h2 { grid-column: 2; margin: 0; font-size: 17px; font-weight: 600; }
.done { grid-column: 3; justify-self: end; min-height: 44px; padding: 0 10px; color: var(--accent); font-weight: 600; }
.grabber { display: none; }
.sheet-body { overflow-y: auto; padding: 4px 20px 24px; }
.sheet .group-label { margin-top: 18px; }
.card { background: var(--card); border-radius: var(--r); overflow: hidden; margin-bottom: 4px; }
.card + .card { margin-top: 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 6px 16px; position: relative; }
.row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.row > span { flex: none; max-width: 48%; font-size: 17px; }
.row small { color: var(--label-3); font-size: 13px; }
.row input[type="range"] { flex: 1; max-width: 260px; }
.footnote { margin: 18px 16px 0; font-size: 13px; color: var(--label-2); }
@media (max-width: 640px) {
  .sheet { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .grabber { display: block; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--fill-strong); }
}

/* controls */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 28px; background: transparent; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--fill-strong); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill-strong); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.06); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.switch { -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 51px; height: 31px; margin: 0; border-radius: 16px; background: var(--fill-strong); cursor: pointer; transition: background 0.25s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25); transition: transform 0.25s var(--ease); }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

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