/* ============================================================
   INDIEWRIGHT — MOBILE LAYOUT (mobile.html only)
   Target: ~390–430px wide, native-app feel. On wider viewports
   (this file being opened on a desktop browser to preview) the
   app is centered inside a phone-proportioned frame so the
   experience still reads correctly.
   ============================================================ */

body { overflow-x: hidden; }

.viewport-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: var(--bg);
}

/* Phone frame — only takes visual effect above 560px so real
   phones always get an edge-to-edge, full-width experience. */
.app-frame {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Real phones (below the 560px frame breakpoint) need a DEFINITE height,
   not just a minimum. `min-height: 100vh` alone leaves height auto, so the
   shell grows to fit its content, `flex: 1` on .app-content has nothing
   fixed to resolve against, and the scroller never scrolls — the whole
   document stretches instead and the bottom nav and mini player scroll off
   the screen mid-playback.

   This only ever broke on real phones: at >=560px .app-frame is given an
   explicit 844px height for the desktop preview frame, which accidentally
   made the bug invisible in a desktop browser. dvh keeps it correct while
   mobile browser chrome hides and reveals. */
@media (max-width: 559.98px) {
  .viewport-shell { height: 100vh; height: 100dvh; }
  .app-frame { height: 100%; min-height: 0; }
  /* The preview bar is the first row of the frame's existing flex column, so
     it takes its height out of the frame rather than adding to the page. */
  .preview-bar { flex: 0 0 auto; }
}

@media (min-width: 560px) {
  .viewport-shell { align-items: center; padding: 28px 0; }
  .app-frame {
    min-height: 844px;
    height: 844px;
    border-radius: 44px;
    border: 10px solid #05060A;
    box-shadow: var(--shadow-lg);
  }
  .app-frame::before {
    content: "";
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 120px; height: 26px;
    background: #05060A;
    border-radius: 0 0 16px 16px;
    z-index: 50;
  }
}

.stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage.hidden { display: none; }

/* ---------- Safe areas ---------- */
.safe-top { padding-top: max(18px, env(safe-area-inset-top)); }
.safe-bottom { padding-bottom: max(18px, env(safe-area-inset-bottom)); }

/* ---------- Splash ---------- */
.splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px;
  background:
    radial-gradient(circle at 50% 18%, rgba(213,174,104,0.14), transparent 55%),
    linear-gradient(180deg, #0F1115 0%, #12141B 60%, #0F1115 100%);
  position: relative;
}
.splash-mark {
  width: 74px; height: 74px;
  border-radius: 22px;
  background: linear-gradient(155deg, var(--gold-strong), var(--plum) 130%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-gold);
  margin-bottom: 26px;
  animation: mark-in 900ms var(--ease) both;
}
.splash-mark svg { width: 34px; height: 34px; stroke: #16110A; }
@keyframes mark-in {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.splash-name {
  font-family: var(--font-serif);
  font-size: 30px;
  letter-spacing: 0.2px;
  animation: fade-up 900ms 120ms var(--ease) both;
}
.splash-tagline {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 260px;
  line-height: 1.5;
  animation: fade-up 900ms 240ms var(--ease) both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.splash-footer {
  position: absolute;
  left: 28px; right: 28px; bottom: 0;
  padding-bottom: max(30px, env(safe-area-inset-bottom));
  animation: fade-up 900ms 360ms var(--ease) both;
}
.splash-dots { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.splash-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong); }
.splash-dots span:first-child { background: var(--gold); }

/* ---------- Auth ---------- */
.auth-screen { flex: 1; display: flex; flex-direction: column; padding: 20px 22px 0; overflow-y: auto; }
.auth-header { margin: 8px 0 22px; }
.auth-header h1 { font-size: 25px; margin-bottom: 6px; }
.auth-tabs { display: flex; background: var(--surface); border-radius: var(--r-full); padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; text-align: center; padding: 10px 0; border-radius: var(--r-full); background: none; border: none; color: var(--text-tertiary); font-weight: 600; font-size: 13.5px; transition: all var(--fast) var(--ease); }
.auth-tab.is-active { background: var(--gold); color: #1A1408; }
.auth-panel.hidden { display: none; }
.authway-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.authway-btn { justify-content: flex-start; padding-left: 18px; position: relative; }
/* .authway-mark, .auth-footer-note — shared, see styles.css */
.authway-btn .badge { position: absolute; right: 14px; }
.auth-footer-note { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

/* ---------- Role selection ---------- */
.role-screen { flex: 1; display: flex; flex-direction: column; padding: 28px 22px 0; }
.role-list { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.role-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 18px;
  transition: all var(--fast) var(--ease);
}
.role-card-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--gold); flex-shrink: 0; }
.role-card-title { font-size: 15.5px; font-weight: 700; margin-bottom: 3px; }
.role-card-desc { font-size: 12.5px; color: var(--text-tertiary); line-height: 1.4; }
.role-card.is-selected { border-color: var(--gold); background: var(--card-hover); box-shadow: 0 0 0 1px var(--gold) inset; }
.role-card-check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: transparent; transition: all var(--fast) var(--ease); }
.role-card.is-selected .role-card-check { background: var(--gold); border-color: var(--gold); color: #1A1408; }
.role-footer { margin-top: auto; padding: 20px 0 max(24px, env(safe-area-inset-bottom)); }

/* ---------- App shell ---------- */
.app-shell { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: rgba(15,17,21,0.86);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30;
}
.app-header-brand { display: flex; align-items: center; gap: 9px; }
.app-header-brand .mark-sm { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(155deg, var(--gold-strong), var(--plum) 130%); display: flex; align-items: center; justify-content: center; }
.app-header-brand .mark-sm svg { width: 14px; height: 14px; stroke: #16110A; }
.app-header-title { font-family: var(--font-serif); font-size: 17px; }
.app-header-actions { display: flex; align-items: center; gap: 6px; }
/* .icon-btn, .icon-btn .dot — shared, see styles.css */

/* min-height:0 is load-bearing. A flex item's automatic minimum size is
   its content size, so without this the scroller refuses to shrink, grows
   to fit its content, and takes the document with it — which unpins the
   bottom nav and the mini player and lets them scroll off the screen. */
.app-content { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 18px 12px; }
.app-content [data-view] { animation: fade-up 260ms var(--ease) both; }

.placeholder-screen { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 60px 12px 30px; }
.placeholder-badge { width: 60px; height: 60px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--gold); margin-bottom: 18px; }

/* Home welcome (custom, richer than generic placeholder) */
.home-welcome { padding: 6px 2px 26px; }
.home-welcome h1 { font-size: 24px; margin-top: 4px; }
.home-welcome .eyebrow { display: block; margin-bottom: 6px; }

/* Mini player — visual styling lives in styles.css (shared with
   desktop); this is just mobile placement, inline above the tab bar. */
.mini-player { margin: 0 12px 8px; }

/* Bottom nav */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: rgba(15,17,21,0.92);
  backdrop-filter: blur(10px);
  padding: 8px 6px max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--text-tertiary);
  padding: 6px 2px; font-size: 10.5px; font-weight: 600;
  transition: color var(--fast) var(--ease);
}
.nav-item .icon { transition: transform var(--fast) var(--ease); }
.nav-item.is-active { color: var(--gold); }
.nav-item.is-active .icon { transform: translateY(-1px); }
.nav-item.hidden { display: none; }
.discover-nav-item { margin-top: -11px; }
.discover-nav-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #17120a; border: 4px solid var(--bg); box-shadow: 0 4px 14px rgba(0,0,0,.36); }
.discover-nav-icon .icon { width: 17px; height: 17px; fill: currentColor; }
.discover-nav-item.is-active .discover-nav-icon { background: var(--gold-strong); box-shadow: 0 0 0 3px var(--gold-soft),0 5px 16px rgba(0,0,0,.4); }
.discover-view { margin: -18px -18px -12px; }
.discover-view .discover-header { align-items: center; margin: 0; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.discover-view .discover-header .eyebrow { display: none; }
.discover-view .discover-header h2 { font-size: 21px; }
.discover-view .discover-filter button { padding: 7px 11px; font-size: 11px; }
.discover-view .discover-feed { height: calc(100dvh - 220px); min-height: 0; border-radius: 0; }
.discover-view .discover-card { padding: 0; }
.discover-view .discover-stage { width: 100%; height: 100%; min-height: 540px; border: 0; border-radius: 0; }
.discover-view .discover-play-hit { padding-left: 50px; padding-right: 72px; }
@media (min-width: 560px) { .discover-view .discover-feed { height: 624px; } }

/* Bottom sheet triggers list */
/* .list-row — shared, see styles.css */

/* ---------- Book rows / grids (mobile) ---------- */
.home-feed { margin-top: 4px; }
.book-row {
  display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 0 4px; margin: 0 -18px; padding-left: 18px; padding-right: 18px;
}
.book-row::-webkit-scrollbar { display: none; }
.book-row[data-variant="standard"] .book-card { width: 128px; }
.book-row[data-variant="continue"] .book-card { width: 210px; }

.explore-header { padding-top: 2px; margin-bottom: 20px; }
.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 12px; }

/* ---------- Sheets: search + quick preview ---------- */
.sheet-tall { max-height: 92vh; height: 86vh; }
.search-sheet-header { display: flex; align-items: center; gap: 10px; padding: 4px 18px 14px; }
.qp-body { padding: 4px 20px 24px; }

/* ---------- Book Detail + Player (Part 3/4) — mobile placement;
   shared visual styling for both is in styles.css. ---------- */
#playerInfoSheet .sheet-body { padding: 6px 20px 24px; }
.player-bottom-controls { padding-bottom: max(22px, env(safe-area-inset-bottom, 0px)); }
.detail-topbar { padding-top: max(14px, env(safe-area-inset-top, 0px)); }

/* ---------- Design system screen (mobile paddings) ---------- */
.ds-screen { position: fixed; inset: 0; background: var(--bg); z-index: 500; display: flex; flex-direction: column; }
.ds-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.ds-body { flex: 1; overflow-y: auto; padding: 20px 18px 60px; }
.ds-section { margin-bottom: 36px; }
.ds-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); margin-bottom: 14px; }
.ds-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ds-swatch { width: 100%; }
.ds-swatch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ds-swatch-item { border-radius: var(--r-md); padding: 14px; border: 1px solid var(--border); }
.ds-swatch-chip { height: 40px; border-radius: var(--r-sm); margin-bottom: 8px; }

/* Toast stack position (mobile) */
.toast-stack { top: max(14px, env(safe-area-inset-top)); left: 14px; right: 14px; align-items: stretch; }
.toast-stack .toast { max-width: none; }

/* Sheet is already positioned fixed:inset via styles.css .sheet-overlay */

/* Small screens: ensure forms never overflow */
input, .btn { min-width: 0; }

/* Google draws its own sign-in button into this mount (see
   mountGoogleButtons). It is an iframe of a fixed width, so it is centred
   rather than stretched — forcing it wider only leaves a gap inside. */
.gsi-mount { display: flex; justify-content: center; width: 100%; }
.gsi-mount > div { max-width: 100%; }
