/* ============================================================
   Components — reusable UI primitives
   Every class here is theme-aware via the tokens in tokens.css.
   ============================================================ */

/* Asynchronously rendered post targets are highlighted after a deep link or
   authoritative purchase reload. Outline/box-shadow do not alter layout, so
   an exact saved viewport offset remains exact on iPhone as well. */
.is-post-focus {
  outline: 3px solid color-mix(in srgb, var(--brand) 82%, #fff);
  outline-offset: 4px;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--brand) 18%, transparent),
    var(--shadow);
  scroll-margin-block: 18vh;
}

/* ------------------------------------------------------------------
   ICON
   Monochrome SVG rendered as a CSS mask so it inherits currentColor.
   <span class="icon" style="--icon:url(../icons/lock.svg)"></span>
   Size with the --icon-size custom property or a modifier class.
   ------------------------------------------------------------------ */
.icon {
  display: inline-block;
  flex: none;
  width: var(--icon-size, 16px);
  height: var(--icon-size, 16px);
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}
.icon--sm { --icon-size: 13px; }
.icon--md { --icon-size: 20px; }
.icon--lg { --icon-size: 26px; }
.icon--xl { --icon-size: 35px; }

/* Brand-tinted section icon (bare glyph, no container) */
/* 30px, not the 35px of .icon--xl. Declared after .icon--xl so it wins on
   source order at equal specificity. The nudge optically centres it against
   the title's cap height now that .section__head aligns to flex-start. */
.section-icon { color: var(--brand); --icon-size: 30px; margin-top: 2px; }

/* ------------------------------------------------------------------
   PLACEHOLDER MEDIA  (--ph-1 … --ph-10)
   Stands in for every model photo / post image in this handoff.
   Pair .ph with a palette modifier; add .ph--avatar for round avatars
   (which use a simpler two-stop gradient) and put initials inside.
   ------------------------------------------------------------------ */
.ph {
  position: relative;
  background-color: var(--card-alt);
  background-image: var(--ph-image);
  background-size: cover;
  background-position: center 22%;
  overflow: hidden;
}
/* grain overlay — softens the flat gradient */
.ph::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  pointer-events: none;
}
.ph--avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background-image: var(--ph-avatar);
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
}
.ph--avatar::after { display: none; }

.ph-1  { --ph-image: radial-gradient(120% 90% at 12% 0%, #8FB7FF 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #C9B4FF 0%, transparent 62%), linear-gradient(155deg, #E3ECFF, #BFD2F5); --ph-avatar: linear-gradient(135deg, #8FB7FF, #C9B4FF); }
.ph-2  { --ph-image: radial-gradient(120% 90% at 12% 0%, #F5A9C8 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #B9C8FF 0%, transparent 62%), linear-gradient(155deg, #F6E3F0, #D9C2E8); --ph-avatar: linear-gradient(135deg, #F5A9C8, #B9C8FF); }
.ph-3  { --ph-image: radial-gradient(120% 90% at 12% 0%, #9BD7E8 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #C4B0F2 0%, transparent 62%), linear-gradient(155deg, #E1F0F6, #BFD0EE); --ph-avatar: linear-gradient(135deg, #9BD7E8, #C4B0F2); }
.ph-4  { --ph-image: radial-gradient(120% 90% at 12% 0%, #F5C6A5 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #D9AEE3 0%, transparent 62%), linear-gradient(155deg, #F8ECE0, #E3C9DD); --ph-avatar: linear-gradient(135deg, #F5C6A5, #D9AEE3); }
.ph-5  { --ph-image: radial-gradient(120% 90% at 12% 0%, #A8DECC 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #9FC1F5 0%, transparent 62%), linear-gradient(155deg, #E3F3EC, #C2D5F0); --ph-avatar: linear-gradient(135deg, #A8DECC, #9FC1F5); }
.ph-6  { --ph-image: radial-gradient(120% 90% at 12% 0%, #E8B4B8 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #A9BFF2 0%, transparent 62%), linear-gradient(155deg, #F6E8E6, #D5C6EA); --ph-avatar: linear-gradient(135deg, #E8B4B8, #A9BFF2); }
.ph-7  { --ph-image: radial-gradient(120% 90% at 12% 0%, #B8C9F7 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #E8B6D9 0%, transparent 62%), linear-gradient(155deg, #EAF0FB, #D6C8ED); --ph-avatar: linear-gradient(135deg, #B8C9F7, #E8B6D9); }
.ph-8  { --ph-image: radial-gradient(120% 90% at 12% 0%, #F2CDA0 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #B4C6F0 0%, transparent 62%), linear-gradient(155deg, #FAF0DF, #DCCBE8); --ph-avatar: linear-gradient(135deg, #F2CDA0, #B4C6F0); }
.ph-9  { --ph-image: radial-gradient(120% 90% at 12% 0%, #A5CBF2 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #D9B6E8 0%, transparent 62%), linear-gradient(155deg, #E6F0FA, #C9CFF0); --ph-avatar: linear-gradient(135deg, #A5CBF2, #D9B6E8); }
.ph-10 { --ph-image: radial-gradient(120% 90% at 12% 0%, #EFB9A8 0%, transparent 58%), radial-gradient(130% 100% at 88% 100%, #B0C9EE 0%, transparent 62%), linear-gradient(155deg, #F8EAE2, #D8CBE9); --ph-avatar: linear-gradient(135deg, #EFB9A8, #B0C9EE); }

/* ------------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--text-base);
  white-space: nowrap;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-brand); }
.btn--solid   { background: var(--brand); color: #fff; }
.btn--ghost   { background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn--quiet   { color: var(--ink-soft); }
.btn--quiet:hover { color: var(--ink); }
.btn--danger  { background: var(--card); border: 1px solid color-mix(in srgb, var(--heart) 45%, var(--line)); color: var(--heart); }
.btn--warn    { background: var(--star); color: #3a2a00; font-weight: 800; }
.btn--sm      { padding: 7px 13px; font-size: 12px; }
.btn--lg      { padding: 13px 22px; font-size: var(--text-md); }
.btn--block   { width: 100%; }

/* Round icon-only button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.btn-icon:hover { color: var(--brand); border-color: var(--brand); }
.btn-icon--sm { width: 26px; height: 26px; }

/* ------------------------------------------------------------------
   CARD
   ------------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card--flat   { box-shadow: none; }
.card--inset  { background: var(--surface); box-shadow: none; border-radius: var(--radius-md); }
.card--pad    { padding: var(--space-5); }
.card--dashed { border-style: dashed; box-shadow: none; }
.card--hover  { transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.card--hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

/* ------------------------------------------------------------------
   CHIPS & BADGES
   ------------------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--card-alt);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip--brand  { background: color-mix(in srgb, var(--brand) 11%, transparent); border-color: transparent; color: var(--brand); }
.chip--online { background: color-mix(in srgb, var(--online) 14%, transparent); border-color: transparent; color: var(--online); }
.chip--star   { background: color-mix(in srgb, var(--star) 18%, transparent);  border-color: transparent; color: var(--star); }
.chip--heart  { background: color-mix(in srgb, var(--heart) 15%, transparent); border-color: transparent; color: var(--heart); }
.chip--solid  { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Small uppercase label badge, e.g. NEW / TOP / FREE */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: #fff;
}
.badge--overlay { background: rgba(10,14,22,.6); backdrop-filter: blur(3px); }

/* Live status dot */
.dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--online); flex: none; }
.dot--ring { border: 2px solid var(--card); width: 12px; height: 12px; }

/* ------------------------------------------------------------------
   SEGMENTED CONTROL / TABS
   ------------------------------------------------------------------ */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--card-alt);
  border: 1px solid var(--line);
}
.segmented__btn {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.segmented__btn:hover { color: var(--ink); }
/* --brand text on --card is what the refined prototype uses for every one of
   these controls; the lift is part of it. Lived in profile_v2.css until My
   Feed needed the same switch to look the same. */
.segmented__btn[aria-selected="true"] {
  background: var(--card);
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(16, 24, 40, .14);
}

/* Pill tab row (Girls / Guys, Trending sub-tabs, Discover filters) */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.tab:hover { color: var(--ink); border-color: var(--brand); }
.tab[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ------------------------------------------------------------------
   SECTION HEADER  (bare brand icon + title + subtitle + action)
   ------------------------------------------------------------------ */
.section        { margin-bottom: var(--space-10); }
.section__head  { display: flex; align-items: flex-start; gap: 11px; }
.section__title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xl); }
.section__sub   { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* ------------------------------------------------------------------
   FORM FIELDS
   ------------------------------------------------------------------ */
.field { display: block; }
.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 700;
}
.field__hint { display: block; margin-top: 5px; font-size: 11px; color: var(--ink-soft); }

.input, .textarea, .select {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}
.textarea { min-height: 64px; resize: vertical; font-family: inherit; }

/* Search box with a leading icon */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
}
.search__input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-size: var(--text-base); }

/* ------------------------------------------------------------------
   NOTE / CALLOUT
   ------------------------------------------------------------------ */
.note {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--brand) 7%, var(--card));
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--ink-soft);
}
.note__icon { color: var(--brand); margin-top: 1px; --icon-size: 15px; }
.note strong { color: var(--ink); }

/* ------------------------------------------------------------------
   MODAL
   ------------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 36px 16px;
  overflow: auto;
  background: rgba(16,24,40,.55);
  animation: fade var(--dur) ease;
}
.modal {
  width: 580px;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lift);
  animation: pop var(--dur) ease;
  overflow: hidden;
}
.modal--sm   { width: 350px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal__title{ font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.modal__body { padding: 20px 22px; display: flex; flex-direction: column; gap: var(--space-4); }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }
.modal__close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-pill);
  background: var(--card-alt);
  color: var(--ink-soft);
}
.modal__close:hover { color: var(--ink); }

/* A single purchase dialog serves membership, extra and the sequential
   membership+extra flow. Its body scrolls independently on short iPhone
   viewports, while the actions remain reachable at the bottom. */
.purchase-modal {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 72px);
  max-height: calc(100dvh - 72px);
}
.purchase-modal .modal__close {
  width: 44px;
  height: 44px;
}
.purchase-modal__body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.purchase-breakdown {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card-alt);
}
.purchase-breakdown__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 13px;
  color: var(--ink-soft);
}
.purchase-breakdown__row + .purchase-breakdown__row {
  border-top: 1px solid var(--line);
}
.purchase-breakdown__row strong { color: var(--ink); white-space: nowrap; }
.purchase-breakdown__row--total { color: var(--ink); font-weight: 700; }
.purchase-modal__renewal { color: var(--ink-soft); font-size: var(--text-sm); }
.purchase-modal__status {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--card-alt);
  color: var(--ink-soft);
  font-size: var(--text-sm);
}
.purchase-modal__status:empty { display: none; }
.purchase-modal__status[data-kind="error"] {
  background: color-mix(in srgb, var(--heart) 10%, var(--card));
  color: var(--heart);
}
.purchase-modal__status[data-kind="success"] {
  background: color-mix(in srgb, var(--online) 10%, var(--card));
  color: var(--online);
}
.purchase-modal__credits { align-self: flex-start; }
.purchase-modal__foot { flex: none; }

@media (max-width: 480px) {
  #fanclub-purchase-modal {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .purchase-modal { max-height: calc(100vh - 24px); }
  .purchase-modal { max-height: calc(100dvh - 24px); }
  .purchase-modal__foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .purchase-modal__foot .btn { flex: 1; }
}

/* ------------------------------------------------------------------
   TOAST
   ------------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 200;
  transform: translateX(-50%);
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--surface);
  font-size: var(--text-base);
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  animation: toast var(--dur) ease;
}

/* ------------------------------------------------------------------
   PROGRESS
   ------------------------------------------------------------------ */
.progress { height: 7px; border-radius: var(--radius-pill); background: var(--card-alt); overflow: hidden; }
.progress__bar { height: 100%; border-radius: var(--radius-pill); background: var(--online); }
