/*
 * MeowTarot — Phase 5: Profile Page Structural Theme
 * css/profile.css
 * ─────────────────────────────────────────────────────────────────────────
 *
 * Replaces the Phase 4 profile.html styling with a layout that matches the
 * design doc's ScreenProfile:
 *   - Top eyebrow row (YOUR PRACTICE · บันทึกการเดินทาง)
 *   - Streak hero (big gradient italic number)
 *   - Progress panel (white card with rose-gold bar + pearl + Moonveil info)
 *   - Decks strip (horizontal scroll, 72×102 thumbnails)
 *   - Lifetime stats (dark plum 3-col panel)
 *   - Plus the existing functional surfaces below: identity (signed-in info),
 *     achievements, history, sign-in CTA — restyled to feel consistent.
 *
 * REQUIRES: css/theme-tokens.css (--mt-* namespace).
 * LOAD ORDER: LAST. After css/phase-3-redesign.css.
 *
 * SECTIONS:
 *   §1  Page background + shell layout
 *   §2  Top eyebrow row
 *   §3  Streak hero (centered gradient number)
 *   §4  Progress panel (Next: deck + bar + info box)
 *   §5  Decks strip (horizontal scroll thumbnails)
 *   §6  Lifetime stats (dark plum 3-col)
 *   §7  Existing panels restyle (identity, achievements, history, cta)
 *   §8  History list items
 *   §9  Empty-state copy
 * ─────────────────────────────────────────────────────────────────────────
 */


/* §1 — Page background + shell layout */
body[data-page='profile'] {
  background: var(--mt-bg-gradient-daily-after);
  color: var(--mt-plum);
  font-family: var(--mt-font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-page='profile'] .page-shell {
  max-width: 440px;
  margin: 0 auto;
  padding: 8px 24px 110px;
  min-height: calc(100dvh - 60px);
}

body[data-page='profile'] .section-block.reading-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

body[data-page='profile'] .reading-intro {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body[data-page='profile'] .reading-content {
  display: block;
  margin: 0;
}


/* §2 — Top eyebrow row */
body[data-page='profile'] .profile-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  gap: 12px;
}

body[data-page='profile'] .profile-top-row__eyebrow {
  font-size: 11px;
  color: var(--mt-plum-mid);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

body[data-page='profile'] .profile-top-row__eyebrow-th {
  font-family: var(--mt-font-thai);
  font-size: 10px;
  color: var(--mt-plum-mid);
  opacity: 0.85;
  letter-spacing: 0.04em;
  margin-top: 2px;
  text-transform: none;
}


/* §3 — Streak hero (centered gradient number) */
body[data-page='profile'] .profile-streak-hero {
  text-align: center;
  margin-top: 18px;
}

body[data-page='profile'] .profile-streak-hero__eyebrow {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--mt-gold);
  font-weight: 600;
  text-transform: uppercase;
}

body[data-page='profile'] .profile-streak-hero__number {
  font-family: var(--mt-font-display);
  font-size: 124px;
  font-weight: 500;
  font-style: italic;
  background: linear-gradient(135deg, #7a1f56 0%, #e8457a 40%, #e8a838 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  line-height: 0.95;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

body[data-page='profile'] .profile-streak-hero__number-th {
  font-family: var(--mt-font-display-th);
  font-size: 18px;
  color: var(--mt-plum-mid);
  margin-top: 2px;
  font-weight: 600;
}

body[data-page='profile'] .profile-streak-hero__subtitle {
  font-size: 12px;
  color: var(--mt-ink-soft);
  margin-top: 2px;
}


/* §4 — Progress panel */
body[data-page='profile'] .profile-progress-panel {
  margin-top: 22px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: var(--mt-radius-panel);
  padding: 16px 18px;
  box-shadow: var(--mt-soft-shadow);
}

body[data-page='profile'] .profile-progress-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

body[data-page='profile'] .profile-progress-panel__title {
  font-family: var(--mt-font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--mt-plum);
  font-style: italic;
}

body[data-page='profile'] .profile-progress-panel__title-th {
  font-family: var(--mt-font-thai);
  font-size: 11px;
  color: var(--mt-plum-mid);
  margin-top: 1px;
}

body[data-page='profile'] .profile-progress-panel__remaining {
  text-align: right;
}

body[data-page='profile'] .profile-progress-panel__remaining-num {
  font-family: var(--mt-font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--mt-gold);
  font-style: italic;
  line-height: 1;
}

body[data-page='profile'] .profile-progress-panel__remaining-label {
  font-size: 10px;
  color: var(--mt-ink-soft);
  margin-top: 1px;
}

body[data-page='profile'] .profile-progress-bar {
  margin-top: 14px;
  position: relative;
}

body[data-page='profile'] .profile-progress-bar__track {
  height: 12px;
  border-radius: var(--mt-radius-pill);
  background: rgba(61, 26, 92, 0.08);
  overflow: hidden;
  position: relative;
}

body[data-page='profile'] .profile-progress-bar__fill {
  height: 100%;
  background: var(--mt-streak-bar);
  border-radius: var(--mt-radius-pill);
  box-shadow: 0 0 14px rgba(232, 103, 138, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-page='profile'] .profile-progress-bar__pearl {
  position: absolute;
  right: -4px;
  top: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 30%, var(--mt-gold) 70%);
  box-shadow: 0 0 16px rgba(201, 147, 58, 0.7), 0 2px 4px rgba(61, 26, 92, 0.3);
  border: 1.5px solid #fff;
}

body[data-page='profile'] .profile-progress-bar__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--mt-ink-soft);
}

body[data-page='profile'] .profile-progress-panel__blurb {
  margin-top: 14px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(232, 103, 138, 0.12), rgba(201, 147, 58, 0.12));
  border-radius: var(--mt-radius-chip);
  font-size: 11.5px;
  color: var(--mt-plum);
  line-height: 1.5;
  border: 1px solid var(--mt-gold-soft);
}

body[data-page='profile'] .profile-progress-panel__blurb b {
  font-weight: 600;
}

body[data-page='profile'] .profile-progress-panel__blurb-th {
  font-family: var(--mt-font-thai);
  font-size: 11px;
  color: var(--mt-plum-mid);
  margin-top: 2px;
}


/* §5 — Decks strip (horizontal scroll thumbnails) */
body[data-page='profile'] #profile-deck-inventory {
  margin-top: 22px;
}

body[data-page='profile'] #profile-deck-inventory .panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

body[data-page='profile'] #profile-deck-inventory .panel h2 {
  font-family: var(--mt-font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--mt-plum);
  margin: 0 0 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

/* Override the inline-styled grid from deck-inventory.js into a horizontal
 * scroll row of small thumbnails. Selector keys off the inline grid-template
 * so we don't need to touch deck-inventory.js. */
body[data-page='profile'] #profile-deck-inventory .panel > div[style*="grid-template-columns"] {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 8px !important;
  margin-top: 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

body[data-page='profile'] #profile-deck-inventory .panel > div[style*="grid-template-columns"]::-webkit-scrollbar {
  display: none;
}

body[data-page='profile'] #profile-deck-inventory .panel > div[style*="grid-template-columns"] > div {
  flex: 0 0 auto !important;
  width: 88px !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  scroll-snap-align: start;
  align-items: flex-start !important;
}

body[data-page='profile'] #profile-deck-inventory .panel > div[style*="grid-template-columns"] > div img {
  width: 88px !important;
  max-width: 88px !important;
  height: 124px !important;
  aspect-ratio: auto !important;
  object-fit: cover !important;
  border-radius: 8px !important;
  margin-bottom: 6px !important;
  box-shadow: 0 10px 20px -8px rgba(61, 26, 92, 0.4) !important;
  border: 0.5px solid var(--mt-gold-soft);
}

body[data-page='profile'] #profile-deck-inventory .panel > div[style*="grid-template-columns"] > div > div:not(:has(img)) {
  text-align: left !important;
  font-size: 12px !important;
  width: 100% !important;
  font-family: var(--mt-font-display) !important;
  font-weight: 600 !important;
  color: var(--mt-plum) !important;
  line-height: 1.05 !important;
}


/* §6 — Lifetime stats (dark plum 3-col panel) */
body[data-page='profile'] #profile-lifetime-stats {
  margin-top: 18px;
}

body[data-page='profile'] .profile-lifetime-stats {
  background: rgba(61, 26, 92, 0.92);
  border-radius: 18px;
  padding: 14px 18px;
  color: var(--mt-cream);
  display: flex;
  justify-content: space-between;
  box-shadow: 0 14px 28px -14px rgba(61, 26, 92, 0.5);
  gap: 8px;
}

body[data-page='profile'] .profile-lifetime-stat {
  text-align: center;
  flex: 1;
}

body[data-page='profile'] .profile-lifetime-stat__num {
  font-family: var(--mt-font-display);
  font-size: 24px;
  font-weight: 600;
  font-style: italic;
  color: var(--mt-gold-pale);
  line-height: 1;
}

body[data-page='profile'] .profile-lifetime-stat__label {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.85;
}

body[data-page='profile'] .profile-lifetime-stat__label-th {
  font-family: var(--mt-font-thai);
  font-size: 9px;
  margin-top: 1px;
  opacity: 0.7;
}


/* §7 — Existing panels restyle (identity, achievements, history, cta) */
body[data-page='profile'] #profile-identity .panel,
body[data-page='profile'] #profile-achievements .panel,
body[data-page='profile'] #profile-history .panel,
body[data-page='profile'] #profile-cta .panel {
  background: rgba(255, 255, 255, 0.82);
  border-radius: var(--mt-radius-panel);
  border: none;
  box-shadow: var(--mt-soft-shadow);
  padding: 16px 18px;
  margin-top: 18px;
}

body[data-page='profile'] #profile-identity .panel h2,
body[data-page='profile'] #profile-achievements .panel h2,
body[data-page='profile'] #profile-history .panel h2,
body[data-page='profile'] #profile-cta .panel h2 {
  font-family: var(--mt-font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--mt-plum);
  margin: 0 0 10px 0;
}

body[data-page='profile'] #profile-identity .panel p,
body[data-page='profile'] #profile-history .panel p {
  font-size: 13px;
  color: var(--mt-plum);
  line-height: 1.45;
  margin: 0 0 8px 0;
}

body[data-page='profile'] #profile-identity .panel button.ghost,
body[data-page='profile'] #profile-history .panel button.ghost {
  font-family: var(--mt-font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--mt-radius-pill);
  border: 1px solid var(--mt-plum-pale);
  background: transparent;
  color: var(--mt-plum);
  cursor: pointer;
  transition: background 160ms ease;
}

body[data-page='profile'] #profile-identity .panel button.ghost:hover,
body[data-page='profile'] #profile-history .panel button.ghost:hover {
  background: rgba(61, 26, 92, 0.06);
}

body[data-page='profile'] #profile-identity .panel button.primary {
  font-family: var(--mt-font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--mt-radius-pill);
  border: none;
  background: var(--mt-cta-grad);
  color: var(--mt-cream);
  cursor: pointer;
  box-shadow: var(--mt-cta-shadow);
}


/* §8 — History list items */
body[data-page='profile'] .history-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body[data-page='profile'] .profile-history-item {
  border-radius: var(--mt-radius-chip);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(61, 26, 92, 0.08);
}

body[data-page='profile'] .profile-history-item__title {
  font-family: var(--mt-font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--mt-plum);
  margin: 0;
}

body[data-page='profile'] .profile-history-item__cards {
  font-size: 12px;
  color: var(--mt-plum-mid);
  margin: 4px 0;
  line-height: 1.4;
}

body[data-page='profile'] .profile-history-item__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

body[data-page='profile'] .profile-history-item__action {
  font-family: var(--mt-font-body);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--mt-radius-pill);
  border: 1px solid var(--mt-plum-pale);
  background: transparent;
  color: var(--mt-plum);
  cursor: pointer;
  text-decoration: none;
}


/* §9 — Empty-state copy (history when not signed in / no readings yet) */
body[data-page='profile'] .profile-empty-state {
  padding: 4px 0;
}

body[data-page='profile'] .profile-empty-state__title {
  font-family: var(--mt-font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--mt-plum);
  font-style: italic;
  margin: 0;
}

body[data-page='profile'] .profile-empty-state__body {
  font-size: 12px;
  color: var(--mt-plum-mid);
  line-height: 1.45;
  margin: 6px 0 10px 0;
}

body[data-page='profile'] .profile-empty-state__cta {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--mt-radius-pill);
  border: 1px solid var(--mt-plum-pale);
  background: transparent;
  color: var(--mt-plum);
  text-decoration: none;
}


/* §10 — Language toggle pill (right of the Your Practice eyebrow) */
body[data-page='profile'] .profile-lang-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--mt-radius-pill);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--mt-soft-shadow);
  border: 0.5px solid rgba(212, 154, 44, 0.35);
  gap: 2px;
}

body[data-page='profile'] .profile-lang-pill__btn {
  font-family: var(--mt-font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: var(--mt-radius-pill);
  border: none;
  background: transparent;
  color: var(--mt-plum-mid);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

body[data-page='profile'] .profile-lang-pill__btn:hover {
  color: var(--mt-plum);
}

body[data-page='profile'] .profile-lang-pill__btn.is-active {
  background: var(--mt-plum);
  color: var(--mt-cream);
  box-shadow: 0 4px 10px -4px rgba(61, 26, 92, 0.45);
}

body[data-page='profile'] .profile-lang-pill__btn:active {
  transform: scale(0.95);
}


/* §11 — "View all decks · ดูสำรับทั้งหมด" CTA below the horizontal strip */
body[data-page='profile'] .profile-deck-see-all {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 10px;
  padding: 6px 0;
  font-family: var(--mt-font-body);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--mt-gold);
  text-decoration: none;
  letter-spacing: 0.05em;
}

body[data-page='profile'] .profile-deck-see-all:hover {
  color: var(--mt-gold-deep);
}

body[data-page='profile'] .profile-deck-see-all__sep {
  opacity: 0.4;
  font-weight: 400;
}

body[data-page='profile'] .profile-deck-see-all__alt {
  font-family: var(--mt-font-thai);
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.85;
}
