/* StreamFinder design system — zinc base, single emerald accent */
:root {
  --bg: #0B0D10;
  --bg2: #12151A;
  --card: #171B21;
  --card2: #1E232B;
  --line: rgba(255, 255, 255, 0.08);
  --line-hi: rgba(52, 211, 153, 0.5);
  --accent: #34D399;
  --accent-ink: #05130D;
  --text: #F4F6F8;
  --muted: #98A2AE;
  --danger: #F87171;
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); }
#app { max-width: 980px; margin: 0 auto; min-height: 100vh; padding: 0 18px 60px; }
.boot {
  padding: 42vh 0; text-align: center; color: var(--muted);
  font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 0 6px;
}
.brandrow { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brandmark { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.brand small { display: block; font-size: 0.68rem; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; }

select.region {
  font: inherit; background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-size: 0.85rem;
}
select.region:focus { outline: none; border-color: var(--line-hi); }

/* hero + search */
.hero { padding: 30px 0 10px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; max-width: 22ch; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { color: var(--muted); margin-top: 8px; max-width: 52ch; }
.searchwrap { position: sticky; top: 0; z-index: 10; padding: 14px 0; background: linear-gradient(var(--bg) 75%, transparent); }
input.search {
  width: 100%; font: inherit; font-size: 1.05rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 16px 22px;
  transition: border-color 0.15s;
}
input.search::placeholder { color: var(--muted); }
input.search:focus { outline: none; border-color: var(--line-hi); }

/* results grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; padding-top: 8px; }
.tile {
  cursor: pointer; border-radius: var(--radius); overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.16s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--line-hi); }
.tile:active { transform: scale(0.98); }
.tile img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg2); }
.tile .noposter {
  width: 100%; aspect-ratio: 2/3; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.8rem; padding: 10px; text-align: center; background: var(--bg2);
}
.tile .cap { padding: 10px 12px; }
.tile .cap strong { font-size: 0.88rem; display: block; line-height: 1.25; }
.tile .meta { color: var(--muted); font-size: 0.74rem; margin-top: 3px; display: flex; gap: 8px; font-family: var(--mono); }

/* skeletons */
.skel { border-radius: var(--radius); overflow: hidden; background: var(--card); border: 1px solid var(--line); }
.skel .ph { width: 100%; aspect-ratio: 2/3; background: linear-gradient(100deg, var(--card) 40%, var(--card2) 50%, var(--card) 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skel .bar { height: 12px; margin: 12px; border-radius: 6px; background: var(--card2); }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { color: var(--muted); text-align: center; padding: 60px 20px; line-height: 1.6; }
.empty strong { color: var(--text); }

/* detail sheet */
dialog.sheet {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 18px; padding: 0; width: min(94vw, 640px); margin: auto; overflow: hidden;
}
dialog.sheet::backdrop { background: rgba(5, 7, 9, 0.78); backdrop-filter: blur(4px); }
.sheethead { display: flex; gap: 16px; padding: 20px 20px 4px; }
.sheethead img.poster { width: 110px; border-radius: 10px; flex-shrink: 0; }
.sheethead h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.sheethead .meta { color: var(--muted); font-size: 0.8rem; margin-top: 6px; font-family: var(--mono); display: flex; flex-wrap: wrap; gap: 10px; }
.sheetbody { padding: 12px 20px 20px; }
.overview { color: var(--muted); font-size: 0.9rem; line-height: 1.6; max-height: 90px; overflow: hidden; }
.provgroup { margin-top: 16px; }
.provgroup .lbl {
  font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.provrow { display: flex; flex-wrap: wrap; gap: 8px; }
a.prov {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px 7px 7px; font-size: 0.84rem; font-weight: 500;
  transition: border-color 0.15s, transform 0.1s;
}
a.prov:hover { border-color: var(--line-hi); }
a.prov:active { transform: scale(0.97); }
a.prov img { width: 26px; height: 26px; border-radius: 7px; }
.nowhere { color: var(--muted); font-size: 0.88rem; padding: 14px 0 4px; line-height: 1.5; }
a.jw { color: var(--accent); text-decoration: none; font-weight: 500; }
button.close {
  font: inherit; position: absolute; top: 12px; right: 12px;
  background: rgba(11, 13, 16, 0.7); color: var(--text); border: 1px solid var(--line);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 1rem;
}

/* setup */
.setup { max-width: 520px; margin: 8vh auto 0; }
.setup .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 18px; }
.setup label { display: block; font-size: 0.78rem; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }
.setup input {
  width: 100%; font: inherit; background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.setup input:focus { outline: none; border-color: var(--line-hi); }
.setup ol { color: var(--muted); font-size: 0.88rem; line-height: 1.8; padding-left: 20px; margin-top: 8px; }
.setup a { color: var(--accent); }
button.primary {
  font: inherit; font-weight: 600; width: 100%; margin-top: 16px;
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 999px; padding: 14px; cursor: pointer; font-size: 0.95rem;
  transition: transform 0.12s;
}
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--card2); color: var(--text); border: 1px solid var(--line-hi);
  padding: 11px 20px; border-radius: 999px; font-size: 0.85rem; font-weight: 500;
  z-index: 99; max-width: 90vw; text-align: center; animation: pop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.bad { border-color: var(--danger); color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

footer.attrib {
  margin-top: 60px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.72rem; line-height: 1.7;
}
footer.attrib img.tmdb { height: 10px; vertical-align: middle; }

/* ---- UX upgrade pass ---- */
button, .tile, a.prov, select.region { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input.search:focus-visible, select.region:focus-visible { outline: none; }

/* filter chips — 44px touch targets */
.chips { display: flex; gap: 8px; padding: 2px 0 10px; }
.chip {
  font: inherit; font-size: 0.85rem; font-weight: 500; cursor: pointer;
  background: var(--bg2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 18px; min-height: 44px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chip[aria-pressed="true"] { background: rgba(52, 211, 153, 0.12); color: var(--accent); border-color: var(--line-hi); }
.chip:active { transform: scale(0.97); }

.sectionlabel {
  font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin: 18px 0 10px;
}

/* detail sheet backdrop art */
.sheetart { position: relative; height: 150px; background: var(--bg2); }
.sheetart img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheetart::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(rgba(23, 27, 33, 0.15) 0%, rgba(23, 27, 33, 0.55) 60%, var(--card) 100%);
}
.sheethead.overart { margin-top: -64px; position: relative; z-index: 1; }
.sheethead img.poster { border: 2px solid var(--card); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }

.overview.expanded { max-height: none; }
button.morebtn {
  font: inherit; background: none; border: none; color: var(--accent);
  cursor: pointer; padding: 6px 0; font-size: 0.84rem; font-weight: 500; min-height: 32px;
}

button.retry {
  font: inherit; font-weight: 600; margin-top: 14px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 12px 26px; min-height: 44px; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
#app { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

/* install button */
button.installbtn {
  font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 16px; min-height: 44px; padding: 11px 20px;
  background: transparent; color: var(--accent);
  border: 1px solid var(--line-hi); border-radius: 999px;
  transition: background 0.15s, transform 0.12s;
}
button.installbtn:hover { background: rgba(52, 211, 153, 0.08); }
button.installbtn:active { transform: scale(0.97); }

/* ---- availability alerts ---- */
.topright { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* the bell costs header room — drop the tagline rather than wrap the brand */
@media (max-width: 560px) {
  header.top:has(.bell) .brand small { display: none; }
}

button.bell {
  font: inherit; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(52, 211, 153, 0.12); color: var(--accent);
  border: 1px solid var(--line-hi); border-radius: 999px;
  padding: 9px 14px 9px 12px; min-height: 40px;
  transition: background 0.15s, transform 0.12s;
}
button.bell:hover { background: rgba(52, 211, 153, 0.2); }
button.bell:active { transform: scale(0.96); }
.bellcount { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; line-height: 1; }

/* the "tell me when it lands" block inside a title sheet */
.alertbox { margin-top: 14px; }
button.alertbtn {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 13px 18px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 999px;
  transition: transform 0.12s, opacity 0.15s;
}
button.alertbtn:active { transform: scale(0.98); }
button.alertbtn:disabled { opacity: 0.55; cursor: progress; }
.alerthint { color: var(--muted); font-size: 0.78rem; line-height: 1.55; text-align: center; margin-top: 10px; }

.alerton {
  display: flex; align-items: center; gap: 12px;
  background: rgba(52, 211, 153, 0.09); border: 1px solid var(--line-hi);
  border-radius: var(--radius); padding: 14px 14px 14px 16px; color: var(--accent);
}
.alerton-txt { flex: 1; min-width: 0; }
.alerton-txt strong { display: block; font-size: 0.9rem; color: var(--accent); }
.alerton-txt span { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.5; margin-top: 2px; }

button.alertdrop {
  font: inherit; font-size: 0.8rem; font-weight: 500; cursor: pointer; flex-shrink: 0;
  background: var(--card2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; min-height: 40px;
  transition: color 0.15s, border-color 0.15s;
}
button.alertdrop:hover { color: var(--danger); border-color: var(--danger); }
button.alertdrop:disabled { opacity: 0.5; cursor: progress; }

/* the "waiting for" list */
.alertlist { margin-top: 16px; max-height: 58vh; overflow-y: auto; }
.alertrow {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.alertrow:first-child { border-top: none; }
.alertrow img, .alertrow-noart {
  width: 40px; height: 60px; border-radius: 6px; object-fit: cover;
  background: var(--bg2); flex-shrink: 0;
}
.alertrow-txt { flex: 1; min-width: 0; }
.alertrow-txt strong { display: block; font-size: 0.9rem; line-height: 1.3; }
.alertrow-txt span {
  display: block; color: var(--muted); font-size: 0.74rem;
  font-family: var(--mono); margin-top: 3px;
}
