/* TASK-092 — public page tokens.
 *
 * Transcribed from docs/design.md so the shared pages match the app exactly.
 * These values are the same ones lib/app/tokens.dart carries; if the two ever
 * disagree, docs/design.md is right and both are wrong.
 *
 * Light is the default, matching the app. `prefers-color-scheme: dark` is
 * honoured for visitors whose device asks for it — but photography and the
 * chrome overlaid on it stay dark in both, because a collectible photographed
 * against a light frame looks like a product listing rather than a shelf.
 */

:root {
  /* Brand — identical in both themes. */
  --ts-brand: #ff8d28;
  --ts-brand-pressed: #e97d1c;
  --ts-amber: #f5a623;
  --ts-success: #4caf50;
  --ts-danger: #e5484d;

  /* Light ramp: warm paper. */
  --ts-surface-app: #f7f3ee;
  --ts-surface-card: #ffffff;
  --ts-surface-raised: #ede8e1;
  --ts-text-heading: #1c1714;
  --ts-text-body: #7a6f65;
  --ts-text-faint: #9a9089;
  --ts-border: rgba(28, 23, 20, 0.08);
  --ts-border-strong: rgba(28, 23, 20, 0.14);
  --ts-text-on-brand: #1c1714;

  /* Photography stays dark in both themes. */
  --ts-photo-bg: #0c0e16;

  /* docs/design.md § 5 — a sub-pixel hairline. Rounding it to 1px visibly
     coarsens every card. */
  --ts-hairline: 0.7px;

  --ts-radius-sm: 8px;
  --ts-radius-md: 12px;
  --ts-radius-lg: 16px;
  --ts-radius-xl: 22px;
  --ts-radius-pill: 999px;

  --ts-gutter: 18px;
  --ts-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont,
    'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ts-surface-app: #0d0f14;
    --ts-surface-card: #171a21;
    --ts-surface-raised: #1c1f24;
    --ts-text-heading: #f0ede8;
    --ts-text-body: #8a8f9e;
    --ts-text-faint: #676d75;
    --ts-border: rgba(255, 255, 255, 0.08);
    --ts-border-strong: rgba(255, 255, 255, 0.14);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ts-surface-app);
  color: var(--ts-text-heading);
  font-family: var(--ts-font);
  font-size: 14px;
  line-height: 1.5;
  /* The system font stack is the fallback on purpose: a shared link must
     render immediately, and a web font blocking first paint is worse than a
     slightly different typeface on a page a stranger opens once. */
  font-synthesis-weight: none;
}

.ts-page {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 96px; /* clearance for the sticky join banner */
}

/* ---- photography ---- */

.ts-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--ts-photo-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ts-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ts-photo .ts-glyph {
  font-size: 64px;
}

/* Chrome over photography is light-on-dark in both themes. */
.ts-pill {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--ts-radius-pill);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.ts-pill--views {
  right: 10px;
  bottom: 10px;
}

.ts-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.ts-badge--mint {
  background: rgba(76, 175, 80, 0.18);
  color: #1e7a2b;
}

.ts-badge--super {
  background: #eeedfe;
  color: #3c3489;
}

.ts-badge--rare {
  background: #c8922a;
  color: #1c1714;
}

/* ---- content ---- */

.ts-header {
  padding: var(--ts-gutter);
}

.ts-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.25;
}

.ts-meta {
  margin: 4px 0 0;
  color: var(--ts-text-body);
  font-size: 12.5px;
  font-weight: 500;
}

.ts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.ts-chip {
  padding: 3px 9px;
  border-radius: var(--ts-radius-pill);
  background: var(--ts-surface-raised);
  color: var(--ts-text-body);
  font-size: 11px;
  font-weight: 600;
}

.ts-chip--public {
  background: rgba(76, 175, 80, 0.16);
  color: #1e7a2b;
}

.ts-section {
  padding: 0 var(--ts-gutter);
  margin-top: 26px;
}

.ts-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ts-section-head::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ts-brand);
}

.ts-section-head span {
  color: var(--ts-brand);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.ts-rows {
  border: var(--ts-hairline) solid var(--ts-border);
  border-radius: var(--ts-radius-md);
  background: var(--ts-surface-card);
  padding: 0 14px;
}

.ts-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-bottom: var(--ts-hairline) solid var(--ts-border);
}

.ts-row:last-child {
  border-bottom: none;
}

.ts-row dt {
  margin: 0;
  color: var(--ts-text-body);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.ts-row dd {
  margin: 0;
  text-align: right;
  font-size: 12.5px;
  font-weight: 700;
}

.ts-row dd.is-accent {
  color: var(--ts-brand);
}

.ts-prose {
  color: var(--ts-text-body);
  font-size: 13.5px;
  line-height: 1.7;
  margin: 0;
}

/* A link inside prose is the brand orange, like every other link on these
   pages. Without this it inherits the browser default — a blue underline on
   warm paper, which is the one colour nothing else here uses.

   ⚠️ **Scoped to `.ts-prose`, not a bare `a`.** Every link rule in this file is
   scoped to its context (`.ts-footer a`, `.ts-meta a`, `.ts-pager a`, …) so
   each surface picks its own weight against its own background; a global rule
   would quietly restyle all of them. */
.ts-prose a {
  color: var(--ts-brand);
  font-weight: 600;
  text-decoration: none;
}

.ts-prose a:hover,
.ts-prose a:focus-visible {
  text-decoration: underline;
}

/* ---- shelf showcase ---- */

.ts-owner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--ts-gutter);
}

.ts-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--ts-radius-lg);
  background: var(--ts-surface-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  overflow: hidden;
}

.ts-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ts-stage {
  margin: 0 var(--ts-gutter);
  padding: 14px;
  background: var(--ts-photo-bg);
  border: var(--ts-hairline) solid var(--ts-border);
  border-radius: var(--ts-radius-lg);
  display: grid;
  /* minmax(0, 1fr), not 1fr: `1fr` is `minmax(auto, 1fr)` and will not shrink
     below its content's min-content width, so one long collectible name
     ("Lamborghini Aventador Coupé") widened its column and left the two tiles
     visibly different sizes. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.ts-frame {
  display: block;
  text-decoration: none;
  color: inherit;
}

.ts-frame .ts-photo {
  aspect-ratio: 1 / 1.2;
  border: 0.8px solid rgba(245, 166, 35, 0.35);
  border-radius: var(--ts-radius-md);
}

.ts-frame-name {
  margin: 6px 0 0;
  text-align: center;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ts-frame-views {
  margin: 1px 0 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 9.5px;
}

.ts-slot {
  font-size: 9px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.5);
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 6px;
  left: 6px;
}

/* ---- join banner (collectible page only) ---- */

.ts-join {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--ts-gutter);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--ts-surface-card);
  border-top: var(--ts-hairline) solid var(--ts-border);
}

.ts-join-copy {
  flex: 1;
  min-width: 0;
}

.ts-join-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.ts-join-sub {
  margin: 1px 0 0;
  color: var(--ts-text-body);
  font-size: 11px;
}

.ts-btn {
  flex-shrink: 0;
  display: inline-block;
  padding: 11px 18px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--ts-amber), var(--ts-brand));
  color: var(--ts-text-on-brand);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: none;
}

/* ---- report form (TASK-100) ----
   A plain HTML form: the public pages ship no JavaScript and this one has no
   reason to start. Every control is a native element, which is also what makes
   it work in the in-app webviews a shared link tends to open in. */

.ts-form {
  padding: 0 var(--ts-gutter);
}

.ts-fieldset {
  border: var(--ts-hairline) solid var(--ts-border);
  border-radius: var(--ts-radius-md);
  padding: 12px 14px 14px;
  margin: 0 0 18px;
}

.ts-legend {
  padding: 0 6px;
  color: var(--ts-text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ts-radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  font-size: 13.5px;
  color: var(--ts-text-strong);
  cursor: pointer;
}

.ts-radio input {
  /* 2px down so the control sits on the text baseline rather than its box. */
  margin: 2px 0 0;
  accent-color: var(--ts-brand);
  flex-shrink: 0;
}

.ts-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ts-text-body);
  font-size: 12.5px;
  font-weight: 600;
}

.ts-textarea {
  display: block;
  width: 100%;
  /* Without border-box the padding pushes it past the gutter. The prototype
     ships no reset, and this is the trap that costs an afternoon. */
  box-sizing: border-box;
  padding: 10px 12px;
  margin-bottom: 18px;
  border: var(--ts-hairline) solid var(--ts-border);
  border-radius: var(--ts-radius-md);
  background: var(--ts-surface-raised);
  color: var(--ts-text-strong);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}

.ts-btn--block {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.ts-form-foot {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12.5px;
}

.ts-form-foot a {
  color: var(--ts-text-body);
}

/* ---- pager (collection page only) ----
   TASK-093. The collection page is unbounded, unlike the shelf of six it
   replaces, so it is the one public page that can run to a second screenful.
   `justify-content: space-between` with an empty <span> holding the other side
   keeps "Next →" pinned right on page one, where there is no "Previous". */

.ts-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px var(--ts-gutter) 0;
  font-size: 12.5px;
  font-weight: 600;
}

.ts-pager a {
  color: var(--ts-brand);
  text-decoration: none;
}

/* The collection page's header links back to the owner's profile, and it was
   the first link in a .ts-meta line — so it rendered as unstyled browser blue,
   underlined, in the middle of a muted grey subtitle. Caught by looking at it
   at 375pt; no test would have. */

.ts-meta a {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.ts-footer {
  padding: 28px var(--ts-gutter);
  text-align: center;
  color: var(--ts-text-faint);
  font-size: 11px;
}

.ts-footer a {
  color: var(--ts-text-body);
}

/* ---- legal documents (TASK-130) ----
   privacy.html and terms.html. Static files rather than rendered pages: they
   have no per-request content, and a document the App Store review team must
   be able to open should not depend on a Function being warm.

   `.ts-page` carries 96px of bottom padding to clear the sticky join banner
   these pages deliberately do not have — `.ts-doc` gives it back, because a
   screenful of blank under a privacy policy reads as a page that failed to
   finish loading. */

.ts-doc {
  padding-bottom: 0;
}

.ts-doc__toc {
  padding: 0 var(--ts-gutter);
  margin: 18px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
}

.ts-doc__toc li {
  margin: 0;
}

.ts-doc__toc a {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--ts-radius-pill);
  background: var(--ts-surface-raised);
  color: var(--ts-text-body);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
}

.ts-doc h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
  /* An anchored heading jumped under the sticky nothing — but it also landed
     flush against the viewport top, which reads as a cut-off page. */
  scroll-margin-top: 16px;
}

.ts-doc p,
.ts-doc li {
  color: var(--ts-text-body);
  font-size: 13.5px;
  line-height: 1.7;
}

.ts-doc p {
  margin: 0 0 10px;
}

.ts-doc ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.ts-doc li {
  margin-bottom: 6px;
}

.ts-doc strong {
  color: var(--ts-text-heading);
  font-weight: 700;
}

.ts-doc a {
  color: var(--ts-brand);
}

/* The third-party table is the one piece of a privacy policy people actually
   scan, and it is also the widest thing on the page.

   ⚠️ **Two columns, not three.** It was Service / What it receives / Why, which
   needed a 460px minimum — so on a 375pt phone the *entire* Why column sat off
   the right edge, reachable only by a reader who noticed a scrollbar inside a
   box. A column most readers never see is a column that is not in the document.
   The purpose rides under the data instead, in faint ink, and the whole table
   fits without scrolling anywhere.

   `.ts-doc__scroll` stays regardless: it costs nothing and it is what stops a
   future row from making the *page* scroll sideways, which is unreadable rather
   than merely awkward. */

.ts-doc__scroll {
  overflow-x: auto;
  border: var(--ts-hairline) solid var(--ts-border);
  border-radius: var(--ts-radius-md);
  background: var(--ts-surface-card);
}

.ts-doc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}

/* ⚠️ `--ts-text-faint`, not `--ts-text-body`, is what this obviously wants —
   and it measures **3.1:1 on the card surface**, against AA's 4.5. TASK-127
   restricted that token to decorative and disabled states for exactly this
   reason, and a purpose line in a privacy policy is neither. The hierarchy
   comes from size and from the leading "For …" instead of from contrast. */

.ts-doc__why {
  display: block;
  margin-top: 5px;
  color: var(--ts-text-body);
  font-size: 11.5px;
  line-height: 1.5;
}

.ts-doc th,
.ts-doc td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: var(--ts-hairline) solid var(--ts-border);
}

.ts-doc th {
  color: var(--ts-text-heading);
  font-weight: 700;
  white-space: nowrap;
}

.ts-doc td {
  color: var(--ts-text-body);
}

.ts-doc tr:last-child th,
.ts-doc tr:last-child td {
  border-bottom: none;
}

@media (min-width: 641px) {
  .ts-page {
    padding-top: 24px;
  }

  .ts-photo {
    border-radius: var(--ts-radius-lg);
  }
}
