/* TimeReset Facial Age — visual identity copied from the cognitive tool.
   /reference/styles.css and spec §11 are the law: premium, dark, gold.
   Copy patterns from the reference; do not reinvent them. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d2330;
  --text: #f5f7fb;
  --muted: #9aa4b2;
  --line: #2a3242;
  --accent: #d6b36a;
  --success: #52c17a;
  --danger: #ff6b6b;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  overflow-x: hidden;
}

#fa-app {
  min-height: 100vh;
}

.tr-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  box-sizing: border-box;
}

/* Mobile framing only (<=760px): tall screens align from the top so nothing
   gets clipped, and content clears the fixed legal footer pill. Desktop keeps
   the vertically-centered layout untouched. Must come AFTER the base
   .tr-shell rule — same specificity, source order decides the cascade. */
@media (max-width: 760px) {
  .tr-shell {
    align-items: flex-start;
    min-height: 0;
    padding-bottom: 84px;
  }
}

.tr-card {
  width: 100%;
  max-width: 920px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-sizing: border-box;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}

.tr-center {
  text-align: center;
}

.tr-brand {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tr-brand-center {
  justify-content: center;
}

.tr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.tr-title {
  margin: 0 0 10px 0;
  font-weight: 800;
  line-height: 1.1;
}

.tr-subtitle {
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Gold uppercase eyebrow (spec §11: 11px, letter-spacing 0.14em). */
.tr-eyebrow {
  color: rgba(214,179,106,0.95);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ONE gold hook line under titles (spec §11). Never stack two. */
.tr-hook {
  color: var(--accent);
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.45;
  margin: 2px auto 12px;
  max-width: 560px;
}

/* Muted chips row, e.g. `1 photo · ≈ 2 min · Free`. */
.tr-chips {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.tr-chip-sep {
  opacity: 0.4;
}

/* Hairline divider (spec §9/§11). */
.tr-hairline {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.075);
  margin: 18px 0;
}

/* Thin gold progress bar. */
.tr-progress-bar {
  width: 100%;
  height: 10px;
  background: #0e131c;
  border-radius: 999px;
  overflow: hidden;
}

.tr-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #cda75b, #e6c987);
  border-radius: 999px;
}

/* =========================
   Buttons (elevated, tactile)
========================= */

.tr-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.14s ease,
    border-color 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.tr-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.tr-btn:active {
  transform: translateY(0) scale(0.98);
}

.tr-btn-primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(214, 179, 106, 0.18);
}

.tr-btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  filter: brightness(1.05);
}

.tr-btn-primary:active {
  transform: translateY(0) scale(0.985);
  filter: brightness(0.98);
}

.tr-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

/* Quiet inline text link (cancel / back / switch). */
.tr-text-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  font-size: 14px;
}

/* =========================
   Form controls (identifier / login)
========================= */

.tr-form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tr-form-field label {
  font-size: 12px;
  line-height: 1.1;
  color: rgba(201,214,238,0.74);
  font-weight: 760;
  letter-spacing: 0.01em;
}

.tr-form-control {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.105);
  background: rgba(255,255,255,0.045);
  color: var(--text);
  padding: 0 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.tr-form-control::placeholder {
  color: rgba(201,214,238,0.42);
}

.tr-form-control:focus {
  border-color: rgba(214,179,106,0.54);
  background: rgba(255,255,255,0.060);
  box-shadow: 0 0 0 3px rgba(214,179,106,0.10);
}

.tr-form-control-error {
  border-color: rgba(255,107,107,0.72) !important;
  box-shadow: 0 0 0 3px rgba(255,107,107,0.10) !important;
}

.tr-form-error {
  min-height: 15px;
  font-size: 12px;
  line-height: 1.25;
  color: #fecaca;
}

/* Identifier input (S1) — same look as the cognitive intro input. */
.fa-identifier-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: white;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
}

.fa-identifier-input::placeholder {
  color: rgba(255,255,255,0.42);
}

.fa-identifier-input:focus {
  border-color: rgba(214,179,106,0.65);
  box-shadow: 0 0 0 3px rgba(214,179,106,0.12);
}

/* Inner panel (login password block) — cognitive #tr-login-panel pattern. */
.fa-inner-panel {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.075);
  text-align: left;
}

/* =========================
   TOAST NOTIFICATIONS (copied from the cognitive tool)
========================= */

.tr-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.tr-toast {
  min-width: 260px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #1d2330;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: trToastIn 0.25s ease-out;
}

.tr-toast.tr-toast-error {
  border-color: rgba(255, 107, 107, 0.35);
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.10), #1d2330);
}

.tr-toast.tr-toast-warning {
  border-color: rgba(214, 179, 106, 0.30);
  background: linear-gradient(180deg, rgba(214, 179, 106, 0.08), #1d2330);
}

.tr-toast-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 13px;
}

.tr-toast-body {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

@keyframes trToastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .tr-toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .tr-toast {
    min-width: unset;
    max-width: unset;
  }
}

/* =========================
   Flow screens (S3 checklist · S5 review · report)
========================= */

/* Gold-dot bullet list (S3, spec §3). */
.fa-checklist {
  list-style: none;
  margin: 24px auto 0;
  padding: 0;
  max-width: 420px;
  text-align: left;
}

.fa-checklist li {
  position: relative;
  padding: 8px 0 8px 24px;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--text);
}

.fa-checklist li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.fa-review-photo {
  width: 100%;
  max-width: 380px;
  border-radius: 18px;
  border: 1px solid var(--line);
  display: block;
  margin: 18px auto 0;
}

/* S5 consent (spec §8 — default OFF, never pre-checked) */
.fa-consent-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  max-width: 380px;
  margin: 18px auto 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
}

.fa-consent-row input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.fa-consent-micro {
  max-width: 380px;
  margin: 8px auto 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  text-align: left;
}

/* Report (S7) */
.fa-hero-number {
  font-size: clamp(84px, 22vw, 128px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.045em;
  color: var(--text);
  margin-top: 6px;
}

.fa-overall-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(214,179,106,0.24);
  background: rgba(214,179,106,0.08);
  color: rgba(255,255,255,0.88);
  font-size: 14px;
}

.fa-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  text-align: left;
}

@media (max-width: 560px) {
  .fa-metric-grid {
    grid-template-columns: 1fr;
  }
}

.fa-metric-card {
  padding: 14px 15px 13px;
  border-radius: 16px;
  background: rgba(255,255,255,0.032);
  border: 1px solid rgba(255,255,255,0.07);
}

.fa-metric-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.fa-metric-label {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}

.fa-metric-score {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.fa-metric-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #0e131c;
  overflow: hidden;
}

.fa-metric-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #cda75b, #e6c987);
}

.fa-metric-line {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.fa-metric-subrow {
  display: grid;
  grid-template-columns: 76px 1fr 28px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.fa-metric-sublabel {
  font-size: 11.5px;
  color: var(--muted);
}

.fa-metric-subscore {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  text-align: right;
}

/* Anchor chip (spec §9.3) */
.fa-anchor-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.045);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease;
}

.fa-anchor-chip:hover {
  border-color: rgba(214,179,106,0.4);
  color: var(--text);
}

/* Photo & overlays — the mask viewer (spec §9.4) */
.fa-photo-stage {
  position: relative;
  max-width: 380px;
  margin: 16px auto 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.fa-photo-base {
  width: 100%;
  display: block;
}

.fa-photo-mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  transition: opacity 0.18s ease; /* spec: mask fades in 180ms */
  pointer-events: none;
}

.fa-photo-mask.fa-mask-active {
  opacity: 1;
}

.fa-mask-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.fa-mask-chip {
  appearance: none;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.045);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.fa-mask-chip:hover {
  border-color: rgba(255,255,255,0.26);
  color: var(--text);
}

.fa-mask-chip-active {
  color: var(--accent);
  border-color: rgba(214,179,106,0.55);
  background: rgba(214,179,106,0.10);
}

/* S4c — QR handoff (spec §5) */
.fa-qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 252px;
  height: 252px;
  margin: 20px auto 0;
  padding: 16px;
  border-radius: 18px;
  background: #ffffff; /* QR needs quiet-zone contrast */
  box-sizing: border-box;
}

.fa-qr-box img,
.fa-qr-box canvas {
  display: block;
}

.fa-qr-link {
  margin-top: 12px;
  font-family: Consolas, Menlo, monospace;
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* S8 — Manage photos */
.fa-manage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.032);
  border: 1px solid rgba(255,255,255,0.07);
  margin-top: 10px;
  text-align: left;
}

.fa-manage-thumb {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.fa-manage-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fa-manage-info {
  flex: 1;
  min-width: 0;
}

.fa-manage-date {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.fa-manage-meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.fa-manage-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fa-btn-small {
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: 10px;
}

@media (max-width: 560px) {
  .fa-manage-row {
    flex-wrap: wrap;
  }

  .fa-manage-actions {
    flex-direction: row;
    width: 100%;
  }

  .fa-manage-actions .tr-btn {
    flex: 1;
  }
}

/* =========================
   Capture screen (spec §4: dark camera, gold oval, chips, ONE instruction)
========================= */

.fa-capture {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  overflow: hidden;
}

.fa-capture-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Mirror the PREVIEW only — capture reads the raw, un-mirrored frame. */
  transform: scaleX(-1);
}

.fa-capture-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fa-capture-oval {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 0 12px rgba(214, 179, 106, 0.35));
}

.fa-capture-top {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.fa-capture-chips {
  position: absolute;
  top: calc(max(16px, env(safe-area-inset-top)) + 34px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.fa-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(8, 9, 12, 0.5);
  backdrop-filter: blur(4px);
  border: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.fa-chip-red {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.45);
}

.fa-chip-gold {
  color: var(--accent);
  border-color: rgba(214, 179, 106, 0.55);
}

.fa-capture-instruction {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 124px);
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
  min-height: 24px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.fa-capture-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 120px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 44px rgba(214, 179, 106, 0.55);
  pointer-events: none;
}

.fa-capture-shutter {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 44px);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.14s ease;
}

.fa-capture-shutter:active {
  transform: translateX(-50%) scale(0.94);
  background: rgba(255, 255, 255, 0.38);
}

.fa-capture-cancel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, 0.66);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.fa-capture-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.fa-capture-loader-text {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  max-width: 340px;
}

.fa-capture-loader-bar {
  width: min(260px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.fa-capture-loader-fill {
  width: 58%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(214,179,106,0.35), rgba(214,179,106,0.95), rgba(255,255,255,0.65));
  animation: tr-loading-bar 1.15s ease-in-out infinite alternate;
}

@keyframes tr-loading-bar {
  0% {
    transform: translateX(-38%);
    opacity: 0.72;
  }

  100% {
    transform: translateX(76%);
    opacity: 1;
  }
}

/* =========================
   Polish (copied from the cognitive tool)
========================= */

/* Kill the cheap gray tap flash on iOS; :active provides the feedback. */
* {
  -webkit-tap-highlight-color: transparent;
}

.tr-btn:focus-visible,
.tr-text-link:focus-visible,
.tr-form-control:focus-visible,
.fa-identifier-input:focus-visible {
  outline: 2px solid rgba(214, 179, 106, 0.8);
  outline-offset: 2px;
}

/* Gentle entrance on STATIC screens only (spec §11: 180ms fade-in).
   Capture screens must never animate. */
@keyframes trFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.fa-screen .tr-card {
  animation: trFadeIn 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .fa-screen .tr-card {
    animation: none;
  }
}
