/* ============================================================
   StoryForge Store Page — Codex Identity
   ============================================================ */

/* --- Store-specific custom properties --------------------- */

:root {
  --pack-card-bg:            rgba(201, 160, 85, 0.04);
  --pack-card-border:        rgba(201, 160, 85, 0.15);
  --best-value-bg:           rgba(201, 160, 85, 0.08);
  --best-value-border:       rgba(201, 160, 85, 0.4);
}

/* --- Reset ------------------------------------------------ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Base ------------------------------------------------- */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100dvh;
}

/* --- Header ----------------------------------------------- */

.store-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 0.5px solid rgba(201, 160, 85, 0.12);
}

.store-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.store-wordmark {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 400;
  color: var(--gold);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.store-account-link {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .store-account-link:hover {
    color: var(--fg-muted);
  }
}

/* --- Page layout ------------------------------------------ */

.store-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

/* --- Loading state ---------------------------------------- */

.store-loading {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 24px;
}

.store-loading-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 20px;
  color: var(--fg-muted);
  text-align: center;
}

/* --- Brand anchor ----------------------------------------- */

.brand-anchor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-bottom: 56px;
}

.brand-line {
  height: 0.5px;
  width: 110px;
  background: var(--fg-faint);
}

.brand-diamond {
  height: 5px;
  width: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* Smaller variant — wordmark already in header */
.brand-anchor--small .brand-line {
  width: 80px;
}

/* --- Toast ------------------------------------------------ */

.store-toast {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 2px;
  margin-bottom: 2rem;
  border: 0.5px solid var(--container-border);
  background: rgba(201, 160, 85, 0.05);
  color: var(--fg-muted);
}

.store-toast--success {
  background: rgba(201, 160, 85, 0.1);
  color: var(--gold);
  border-color: rgba(201, 160, 85, 0.3);
}

.store-toast--info {
  background: rgba(201, 160, 85, 0.03);
  color: var(--fg-muted);
}

/* --- Balance display -------------------------------------- */

.store-balance-display {
  text-align: center;
  margin-bottom: 56px;
}

.store-balance-label {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.store-balance-number {
  font-family: var(--font-body);
  font-size: 48px;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 6px;
}

.store-balance-number--zero {
  font-size: 42px;
}

.store-balance-meta {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--fg-dim);
}

/* --- Container pattern ------------------------------------ */

.codex-container {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  box-shadow: var(--glass-catchlight), var(--glass-shadow);
  padding: 36px 36px 32px;
  margin-bottom: 24px;
}

/* Label that punches through the top border */
/* SF-VISUAL-01: signet-tick section label (reconciled to match account) */
.codex-label {
  position: static;
  transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 0;
  margin-bottom: 16px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-label);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
}
.codex-label::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 6px rgba(201, 160, 85, 0.5);
  flex-shrink: 0;
}

.codex-label--gold {
  color: var(--gold);
}

/* --- Section headings inside containers ------------------- */

.store-section-title {
  font-family: var(--font-body);
  font-size: 24px;
  color: var(--fg);
  text-align: center;
  margin-bottom: 8px;
}

.store-section-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 32px;
}

/* --- Pack grid -------------------------------------------- */

.store-pack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* --- Pack card -------------------------------------------- */

.pack-card {
  position: relative;
  background: var(--pack-card-bg);
  border: 0.5px solid var(--pack-card-border);
  border-radius: 2px;
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.pack-card--best-value {
  background: var(--best-value-bg);
  border-color: var(--best-value-border);
  padding-top: 28px;
}

.pack-best-value-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 1px 8px;
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--gold);
  border: 0.5px solid var(--gold);
  border-radius: 2px;
  white-space: nowrap;
  text-transform: uppercase;
}

.pack-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.pack-credits-number {
  font-family: var(--font-body);
  font-size: 32px;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 4px;
}

.pack-credits-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.pack-price {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 2px;
}

.pack-per-credit {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12px;
  color: var(--fg-dim);
  margin-bottom: 16px;
}

/* The value line. It sits under the per-episode rate because it is that same
   rate made concrete — what the cheaper rate is actually worth in episodes.
   --fg-label is the informational token (~6.4:1); --fg-faint is decorative
   only and must never carry a number a reader is asked to believe.
   Deliberately quiet: the price is still the loudest thing on the card. */
.pack-value-bonus {
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.35;
  color: var(--fg-label);
  margin-bottom: 16px;
  text-wrap: balance;
}

/* When the value line is present it carries the gap down to the button, so
   rate and value stay one group rather than drifting apart. Class-gated
   rather than :has(), which the older embedded browsers do not all support. */
.pack-card--has-bonus .pack-per-credit {
  margin-bottom: 6px;
}

/* --- Pack button ------------------------------------------ */

.pack-btn {
  all: unset;
  display: block;
  width: 100%;
  text-align: center;
  padding: 9px 0;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  border-radius: 2px;
  cursor: pointer;
  margin-top: auto;
  box-sizing: border-box;
  transition: background 0.12s, border-color 0.12s;
}

.pack-btn--filled {
  background: var(--gold);
  color: var(--bg);
  border: none;
}

@media (hover: hover) and (pointer: fine) {
  .pack-btn--filled:hover {
    background: rgba(201, 160, 85, 0.85);
  }
}

.pack-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.pack-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.pack-error-msg {
  font-family: var(--font-body);
  font-size: 13px;
  color: #c07060;
  margin-top: 8px;
  text-align: center;
}

/* --- Footnote --------------------------------------------- */

.store-footnote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--fg-dim);
  text-align: center;
  padding-top: 32px;
}

/* --- Referrals link --------------------------------------- */

.store-referrals-link {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--gold);
  text-decoration: none;
  padding: 10px 18px;
  border: 0.5px solid var(--gold);
  border-radius: 2px;
  transition: background 0.12s;
  margin: 8px auto 0;
}

@media (hover: hover) and (pointer: fine) {
  .store-referrals-link:hover {
    background: rgba(201, 160, 85, 0.08);
  }
}

/* --- Responsive ------------------------------------------- */

@media (max-width: 599px) {
  .store-pack-grid {
    grid-template-columns: 1fr;
  }

  .pack-card {
    padding: 22px 20px 16px;
  }

  .pack-card--best-value {
    padding-top: 28px;
  }
}

@media (max-width: 479px) {
  .store-header {
    padding: 16px 20px;
  }

  .store-page {
    padding: 40px 20px 64px;
  }

  .codex-container {
    padding: 28px 20px 24px;
  }

  .store-balance-number {
    font-size: 40px;
  }

  .store-balance-number--zero {
    font-size: 36px;
  }
}

/* SF-VISUAL-01: carry the elevated component kit through (presentation-only; reversible - delete this block) */
.pack-btn--filled {
  background: var(--lit-metal);
  color: var(--bg);
  border-radius: var(--btn-radius);
  box-shadow: var(--lit-metal-sheen);
}
@media (hover: hover) and (pointer: fine) {
  .pack-btn--filled:hover { background: var(--lit-metal); filter: brightness(1.06); }
}
.brand-line { height: 1px; background: linear-gradient(90deg, transparent, rgba(201, 160, 85, 0.55)); }
.brand-anchor .brand-line:last-child { background: linear-gradient(90deg, rgba(201, 160, 85, 0.55), transparent); }
.brand-diamond { position: relative; height: 13px; width: 13px; background: transparent; transform: none; }
.brand-diamond::before { content: ""; position: absolute; inset: 0; transform: rotate(45deg); border: 1px solid rgba(201, 160, 85, 0.55); border-radius: 1px; }
.brand-diamond::after { content: ""; position: absolute; inset: 4px; transform: rotate(45deg); background: var(--gold); border-radius: 1px; box-shadow: 0 0 8px rgba(201, 160, 85, 0.6); }

/* ===========================================================================
   SF-VISUAL-06 — store: candlelight, and a real desktop size.
   ---------------------------------------------------------------------------
   Rendered at 1400px, the store was a 680px column stranded in the middle of
   the window: .store-page was capped at 680px with NO desktop breakpoint at
   all, only max-width (mobile-down) queries. The pack grid was hardcoded to
   repeat(3, 1fr), so a fourth pack orphaned onto a second row and its BEST
   VALUE badge collided with the card above it.
   ======================================================================== */

/* Content must sit above the vignette layer that .sf-candlelit paints. */
.store-header,
.store-page,
.store-loading { position: relative; z-index: 1; }

/* The store surfaces adopt the same lit-vellum material as the account page,
   so the two screens read as one product rather than two themes. */
.store-section,
.pack-card {
  background-color: var(--ink-2);
  background-image: linear-gradient(180deg, rgba(201,160,85,0.085), rgba(201,160,85,0.022) 55%, transparent);
  box-shadow: inset 0 1px 0 rgba(201,160,85,0.13), var(--e2);
}

.pack-card {
  transition:
    background-color var(--dur-base) var(--ease),
    border-color     var(--dur-base) var(--ease),
    box-shadow       var(--dur-base) var(--ease),
    transform        var(--dur-base) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .pack-card:hover {
    border-color: var(--gold-l3);
    box-shadow: inset 0 1px 0 rgba(201,160,85,0.22), var(--e3);
    transform: translateY(-2px);
  }
}

/* The purchase button is the primary verb on this page, so it wears ember,
   exactly as the buy affordance does on the account page. */
.pack-buy-btn {
  background: var(--ember-lit);
  color: #1A1206;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 214, 0.55),
    0 2px 10px rgba(0,0,0,0.42),
    var(--ember-glow);
}

@media (hover: hover) and (pointer: fine) {
  .pack-buy-btn:hover { filter: brightness(1.06); }
}

/* --- desktop sizing ------------------------------------------------------- */

/* Four packs deserve one row. At this width the grid goes 4-across, which also
   removes the orphaned fourth card and the badge collision it caused. */
@media (min-width: 900px) {
  .store-page { max-width: 1040px; }
  .store-pack-grid  { grid-template-columns: repeat(4, 1fr); }
}

/* Between the mobile stack and the 4-up row, two columns reads better than a
   cramped three with one left over. */
@media (min-width: 600px) and (max-width: 899px) {
  .store-page { max-width: 760px; }
  .store-pack-grid  { grid-template-columns: repeat(2, 1fr); }
}

/* The badge sits on the card's top edge, so the grid needs row breathing room
   or it overlaps whatever wrapped above it. */
.store-pack-grid { row-gap: 2.25em; }

/* ===========================================================================
   SF-VISUAL-08 — THE DOOR'S COLOURS, ON THE STORE
   ---------------------------------------------------------------------------
   Same correction as the account page. The pass that dissolved this page's
   container and centred its labels has been removed entirely; the grid, the
   borders, the padding and the alignment are all back to what they were.

   What remains is the colour fix: the ground goes flat near-black so the gold
   has something to be brighter than, and the pack cards get a soft gold bloom
   so their borders read as lit edges rather than hairlines.
   ======================================================================== */

/* --- the ground --------------------------------------------------------- */

body {
  background-color: var(--bg);
  background-image: none;
}

body::before,
body::after { content: none; }

/* --- the masthead ------------------------------------------------------- */

/* New markup on this page, so it needs its rules. The store used to open on a
   bare hairline under a small corner wordmark; it now carries the same lockup
   the front door and the account page carry. */
.brand-block {
  text-align: center;
  padding: 8px 0 8px;
}

.brand-wordmark {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 42px;
  font-weight: 400;
  line-height: 1.18;
  padding-bottom: 0.06em;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--gold);
  /* Identical stops to .welcome-wordmark and .brand-wordmark on the account
     page. The bottom stop carries the "g" descender. */
  background: linear-gradient(180deg, #F3D9A2, var(--gold) 58%, #C79350);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(201, 160, 85, 0.26));
}

.brand-edition {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.46em;
  margin: 6px 0 0;
  text-indent: 0.46em;
}

/* The corner wordmark drops to muted nav text so it stops competing with the
   lockup below it for the same job. Colour only; it stays exactly where it is
   and still links home. */
.store-wordmark {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

@media (hover: hover) and (pointer: fine) {
  .store-wordmark:hover { color: var(--fg-muted); }
}

/* --- surfaces ----------------------------------------------------------- */

/* The balance takes the page's light. */
.store-balance-number {
  color: var(--gold);
  text-shadow: 0 0 26px rgba(201, 160, 85, 0.28);
}

.codex-container {
  background-color: var(--ink-1);
  background-image: linear-gradient(180deg, rgba(201, 160, 85, 0.045), transparent 46%);
  border-color: var(--gold-l2);
}

/* THE PACK CARDS. Darker than the container they sit in, with the same soft
   gold bloom the saga cards carry, so the border reads as a lit edge. */
.pack-card {
  background-color: var(--ink-2);
  background-image: linear-gradient(180deg, rgba(201, 160, 85, 0.05), transparent 52%);
  border-color: var(--gold-l2);
  box-shadow:
    inset 0 1px 0 rgba(201, 160, 85, 0.12),
    0 0 20px rgba(201, 160, 85, 0.07),
    var(--e2);
}

.pack-card--best-value {
  background-image: linear-gradient(180deg, rgba(201, 160, 85, 0.10), transparent 52%);
  border-color: var(--gold-l3);
  box-shadow:
    inset 0 1px 0 rgba(201, 160, 85, 0.20),
    0 0 30px rgba(201, 160, 85, 0.12),
    var(--e2);
}

@media (hover: hover) and (pointer: fine) {
  .pack-card:hover {
    border-color: var(--gold-l3);
    box-shadow:
      inset 0 1px 0 rgba(201, 160, 85, 0.20),
      0 0 30px rgba(201, 160, 85, 0.13),
      var(--e3);
  }
}

/* The badge sits on the card edge, so it needs the page ground behind it now
   that the ground is no longer the candle wash. */
.pack-best-value-badge {
  background: var(--bg);
}

/* The best value pack wears ember, the warmer temperature this system reserves
   for the one action a screen most wants to offer. Colour only. */
.pack-card--best-value .pack-btn--filled {
  background: var(--ember-lit);
  color: #1A1206;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 214, 0.55),
    0 3px 12px rgba(0, 0, 0, 0.40),
    var(--ember-glow);
}

/* --- COMPANION is the MOBILE edition ------------------------------------- */

/* Companion names the phone/PWA edition of StoryForge. On a PC — a desktop
   browser, or the Steam desktop client, which is the PC product — there is no
   edition to name: it is just StoryForge. So the mark is hidden by default and
   revealed only on the surfaces it actually describes.

   Hidden by default rather than shown by default on purpose. If a new surface
   ever renders this markup, the safe failure is a missing sub-line, not the
   wrong product name on a PC. */
.brand-edition { display: none; }

/* Phone and small-tablet widths, where the mobile layout is already in play. */
@media (max-width: 760px) {
  .brand-edition { display: block; }
}

/* An installed app on a touch device — a tablet PWA held wider than 760px.
   `pointer: coarse` is the part that keeps the Steam desktop client out: it is
   an installed app too, and can report standalone, but it is a PC with a
   mouse. Width alone would not have separated them. */
@media (display-mode: standalone) and (pointer: coarse) {
  .brand-edition { display: block; }
}
