/* assets/css/dashboard.css
 * Личный кабинет — the iOS app's cabinet language on the web.
 * Tokens come from /style.css (:root): --bg-*, --gold-*, --text-*, --font-display,
 * --font-body, --border-card, --border-subtle. This file only styles the .dsh-*
 * namespace + app-footer; the cycle-picker modal keeps its .iv-v2-dash-modal
 * styles from style.css.
 *
 * Design references (iOS): IVTheme.swift surfaces #131317/#17171C, gold hairlines
 * at 12%/30%, EyebrowLabel small-caps kickers, ContinueListeningCard (cover +
 * serif title + gold capsule progress + Play).
 */

/* ---------- root layout (overrides .auth-page centering for a long page) ---------- */

.auth-page.dsh-root {
  justify-content: flex-start;
  align-items: center;
  padding: 32px 20px 72px;
}

/* (no ::before rule here — style.css hides the .auth-page logo whenever
   .app-header precedes the page, which is always true on the dashboard) */

.dsh-root > section {
  width: 100%;
  max-width: 880px;
}

.dsh-root > section + section {
  margin-top: 20px;
}

/* ---------- hero ---------- */

.dsh-hero {
  position: relative;
  padding: 36px 32px 32px;
  border: 1px solid var(--border-card);
  border-radius: 20px;
  background:
    radial-gradient(ellipse 90% 120% at 15% -20%, var(--gold-glow) 0%, transparent 55%),
    linear-gradient(180deg, #17171c 0%, #131317 100%);
  overflow: hidden;
}

.dsh-hero::after {
  /* thin gold rule under the heading block — the app's hairline motif */
  content: "";
  position: absolute;
  left: 32px;
  bottom: 0;
  width: 64px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-primary), transparent);
  opacity: 0.7;
}

.dsh-eyebrow {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-primary);
}

.dsh-hero h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  text-align: left; /* .auth-page h1 in style.css centers — keep one left axis */
  color: var(--text-primary);
}

.dsh-hero-summary {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 56ch;
}

/* style.css still ships legacy top-level ID rules for these three ids
   (#dash-greeting at 2988/3498 + a 520px media rule, #dash-hero-summary at
   3508, #dash-library-status at 3148/3585). IDs out-specificity the class
   rules above regardless of load order, so restate the intended values at ID
   specificity — this sheet loads after style.css, so later-wins applies. */
#dash-greeting {
  margin: 0 0 10px;
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  line-height: 1.15;
  text-align: left;
  color: var(--text-primary);
}

#dash-hero-summary {
  margin: 0;
  max-width: 56ch;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

#dash-library-status {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

#dash-library-status:empty { margin: 0; }

#dash-library-status a {
  color: var(--gold-primary);
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

#dash-library-status a:hover,
#dash-library-status a:focus-visible {
  color: var(--gold-light);
}

.dsh-hero-summary strong {
  color: var(--gold-light);
  font-weight: 600;
}

.dsh-hero-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- shared panel chrome ---------- */

.dsh-panel {
  background: linear-gradient(180deg, #17171c 0%, #131317 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 28px 32px;
}

.dsh-panel[hidden] { display: none; }

.dsh-panel h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.dsh-panel-kicker {
  /* Continue-listening uses the app's small-caps kicker instead of a serif h2 */
  font-family: var(--font-body) !important;
  font-size: 0.75rem !important;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-primary) !important;
}

.dsh-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.dsh-status {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* NOTE: no `:empty { display:none }` — these are aria-live status regions and
   must stay rendered so their first update is announced (same pattern as
   settings.css). Collapse the gap instead. */
.dsh-status:empty { margin: 0; min-height: 0; }

.dsh-status a { color: var(--gold-primary); text-decoration: underline; text-underline-offset: 3px; }
.dsh-status a:hover, .dsh-status a:focus-visible { color: var(--gold-light); }

/* ---------- continue listening ---------- */

.dsh-continue {
  border-color: var(--border-card);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(201, 168, 76, 0.05);
}

.dsh-continue-body { display: block; }

.dsh-continue-hero {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 20px;
  align-items: start;
}

.dsh-continue-hero .dsh-cover {
  width: 104px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 24px var(--gold-glow);
}

.dsh-continue-meta { min-width: 0; }

.dsh-continue-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

.dsh-continue-author {
  margin: 0 0 6px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.dsh-continue-chapter {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.dsh-progress {
  margin-top: 14px;
  grid-column: 1 / -1;
}

.dsh-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}

.dsh-progress-fill {
  height: 100%;
  min-width: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-light), var(--gold-primary));
}

.dsh-progress-caption {
  margin: 6px 0 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.dsh-continue-cta {
  grid-column: 1 / -1;
  margin-top: 16px;
}

.dsh-continue-cta .btn-primary { width: 100%; justify-content: center; display: inline-flex; }

/* secondary in-progress rows under the hero card */
.dsh-continue-rest {
  list-style: none;
  margin: 20px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dsh-continue-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.9375rem;
}

.dsh-continue-row-title { color: var(--text-primary); min-width: 0; }
.dsh-continue-row-chapter { color: var(--text-tertiary); font-size: 0.8125rem; white-space: nowrap; }

.dsh-continue-row a {
  color: var(--gold-primary);
  text-decoration: none;
  white-space: nowrap;
}
.dsh-continue-row a:hover, .dsh-continue-row a:focus-visible { color: var(--gold-light); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- covers (real art + typographic fallback) ---------- */

.dsh-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-tertiary);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.dsh-cover > img.dsh-cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Designed typographic cover — for the 13 live books with no cover file.
   Dark card, thin gold border + rule, serif title, author name, small round
   author-portrait inset. Never an emoji, never a broken img. */
.dsh-cover-typo {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 12px 10px;
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, rgba(201, 168, 76, 0.12) 0%, transparent 60%),
    linear-gradient(170deg, #1e1e24 0%, #131317 100%);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 10px;
}

.dsh-cover-typo::before {
  content: "";
  display: block;
  width: 28px;
  height: 1px;
  background: var(--gold-primary);
  margin-bottom: 8px;
  flex: none;
}

.dsh-cover-typo-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.8rem, 1.6vw, 0.95rem);
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dsh-cover-typo-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.dsh-cover-typo-portrait {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(201, 168, 76, 0.3);
  flex: none;
  background: var(--bg-tertiary);
}

.dsh-cover-typo-author {
  margin: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- library grid ---------- */

.dsh-book-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 24px 20px;
}

.dsh-book-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.dsh-book-card > a {
  display: block; /* cover link wrapper — avoid inline line-height gap */
}

.dsh-book-card .dsh-cover {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.dsh-book-card:hover .dsh-cover,
.dsh-book-card:focus-within .dsh-cover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 0 20px var(--gold-glow);
}

.dsh-book-card-title {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.dsh-book-card-title a {
  color: inherit;
  text-decoration: none;
}
.dsh-book-card-title a:hover, .dsh-book-card-title a:focus-visible { color: var(--gold-light); }

.dsh-book-card-author {
  margin: 3px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.dsh-book-card-duration {
  margin: 3px 0 0;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.dsh-book-card-foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dsh-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(201, 168, 76, 0.3);
  color: var(--gold-primary);
  background: rgba(201, 168, 76, 0.08);
  white-space: nowrap;
}

.dsh-badge--pick {
  border-color: rgba(159, 176, 200, 0.35);
  color: #9fb0c8;
  background: rgba(159, 176, 200, 0.08);
}

/* "Included" marks a book granted by an active subscription (Apple / legacy
   PayPal blanket access) rather than bought outright — quieter than the gold
   default, since a subscriber sees it on every card. */
.dsh-badge--included {
  border-color: rgba(201, 168, 76, 0.2);
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.03);
}

.dsh-book-card-listen {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gold-primary);
  text-decoration: none;
  white-space: nowrap;
}
.dsh-book-card-listen:hover, .dsh-book-card-listen:focus-visible {
  color: var(--gold-light);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* skeleton shimmer while data loads */
.dsh-skel .dsh-cover {
  background: linear-gradient(100deg, #17171c 40%, #1e1e24 50%, #17171c 60%);
  background-size: 200% 100%;
  animation: dsh-shimmer 1.4s ease-in-out infinite;
  box-shadow: none;
}

.dsh-skel-line {
  height: 12px;
  border-radius: 6px;
  margin-top: 12px;
  background: linear-gradient(100deg, #17171c 40%, #1e1e24 50%, #17171c 60%);
  background-size: 200% 100%;
  animation: dsh-shimmer 1.4s ease-in-out infinite;
}

.dsh-skel-line--short { width: 55%; margin-top: 8px; }

@keyframes dsh-shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -80% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dsh-skel .dsh-cover, .dsh-skel-line { animation: none; }
  .dsh-book-card .dsh-cover { transition: none; }
}

/* empty-state catalog suggestions reuse book cards; label them clearly */
.dsh-grid-note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ---------- subscription ---------- */

.dsh-sub-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 24px;
  margin: 0;
}

.dsh-sub-details dt {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.dsh-sub-details dd {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.dsh-sub-details dd a {
  color: var(--gold-primary);
  text-decoration: none;
}
.dsh-sub-details dd a:hover, .dsh-sub-details dd a:focus-visible {
  color: var(--gold-light);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dsh-sub-status-pastdue { color: #fca5a5; }

.dsh-sub-empty h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dsh-sub-empty p {
  margin: 0 0 16px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 52ch;
}

/* ---------- apps ---------- */

.dsh-apps {
  background:
    radial-gradient(ellipse 80% 130% at 85% -30%, var(--gold-glow) 0%, transparent 55%),
    linear-gradient(180deg, #17171c 0%, #131317 100%);
  border-color: var(--border-card);
}

.dsh-apps-copy {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 56ch;
}

.dsh-apps-note {
  margin: 12px 0 0;
  font-size: 0.8125rem;
  color: var(--gold-primary);
}

/* ---------- account ---------- */

.dsh-account-email {
  margin: 0 0 14px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.dsh-account-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.dsh-account-links li {
  border-top: 1px solid var(--border-subtle);
}

.dsh-account-links li:first-child { border-top: none; }

.dsh-account-links a {
  display: block;
  padding: 12px 2px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  text-decoration: none;
}

.dsh-account-links a:hover,
.dsh-account-links a:focus-visible {
  color: var(--gold-light);
}

.dsh-account-links a::after {
  content: " →";
  color: var(--text-tertiary);
}

/* ---------- banners keep their ids; give them panel-consistent chrome ---------- */

#verify-email-banner,
#past-due-banner,
#email-change-pending-banner {
  width: 100%;
  max-width: 880px;
  background: #2a230f;
  border: 1px solid #5a4a1f;
  border-radius: 12px;
  padding: 12px 16px;
  color: #f5d56e;
  margin-bottom: 16px;
}

#verify-email-banner p,
#past-due-banner p,
#email-change-pending-banner p { margin: 0; font-size: 0.9rem; line-height: 1.5; }

#verify-email-banner a,
#past-due-banner a { color: var(--gold-light); }

#dismiss-banner {
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid #5a4a1f;
  border-radius: 6px;
  background: transparent;
  color: #a89260;
  font-size: 0.8125rem;
}

/* ---------- focus visibility (a11y) ---------- */

.dsh-root a:focus-visible,
.dsh-root button:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- footer ---------- */

.app-footer {
  margin: 48px auto 24px;
  padding: 0 24px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.app-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.app-footer a:hover { color: var(--gold-primary); }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .auth-page.dsh-root { padding: 24px 14px 56px; }
  .dsh-hero { padding: 26px 20px 24px; }
  .dsh-hero::after { left: 20px; }
  .dsh-panel { padding: 22px 18px; }
  .dsh-book-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px 14px; }
  .dsh-continue-hero { grid-template-columns: 84px 1fr; gap: 14px; }
  .dsh-continue-hero .dsh-cover { width: 84px; }
  .dsh-continue-title { font-size: 1.2rem; }
  .dsh-sub-details { grid-template-columns: 1fr; gap: 2px 0; }
  .dsh-sub-details dd { margin-bottom: 10px; }
}
