/* ==========================================================================
   T-Forward Alpine — core theme
   Colorado alpine palette, glassmorphism, Cinzel / Outfit / Plus Jakarta Sans
   / JetBrains Mono. Shared by every page: marketing, auth, studio, admin.
   ========================================================================== */

:root {
  /* Surface */
  --bg-base: #070d12;
  --bg-raise: #0b141c;
  --card-bg: rgba(13, 23, 33, 0.78);
  --card-solid: #0d1721;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(13, 148, 136, 0.35);
  --field-bg: rgba(7, 13, 18, 0.7);

  /* Alpine palette */
  --spruce: #0d9488;
  --spruce-bright: #5eead4;
  --pine-glow: rgba(13, 148, 136, 0.18);
  --aspen-gold: #f59e0b;
  --aspen-glow: rgba(245, 158, 11, 0.22);
  --sky-blue: #38bdf8;
  --danger: #f87171;
  --success: #34d399;

  /* Ink */
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Type */
  --font-display: 'Cinzel', Georgia, serif;
  --font-ui: 'Outfit', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Rhythm */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-card: 0 20px 45px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 30px 60px rgba(0, 0, 0, 0.6);
}

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

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  /*
   * `overflow-x: hidden` turns <body> into a scroll container, which silently
   * disables `position: sticky` for every descendant — the mobile preview
   * simply scrolls away with no error anywhere. `clip` prevents sideways
   * scrolling the same way WITHOUT creating a scroll container. The `hidden`
   * line stays first as a fallback for browsers that predate `clip`.
   */
  overflow-x: hidden;
  overflow-x: clip;
  line-height: 1.55;
  background-image:
    radial-gradient(at 15% 10%, var(--pine-glow) 0px, transparent 45%),
    radial-gradient(at 85% 20%, var(--aspen-glow) 0px, transparent 40%),
    radial-gradient(at 50% 90%, rgba(56, 189, 248, 0.08) 0px, transparent 60%);
  background-attachment: fixed;
}

body.app-body {
  display: flex;
  justify-content: center;
  padding: 40px 20px 80px;
}

/* The ridgeline that anchors every page to the ground. */
.mountain-backdrop {
  position: fixed; bottom: 0; left: 0; right: 0; height: 280px;
  pointer-events: none; z-index: 0; opacity: 0.18;
  background-repeat: no-repeat; background-position: bottom center; background-size: cover;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320' preserveAspectRatio='none'%3E%3Cpath fill='%230d9488' fill-opacity='0.4' d='M0,192L80,165.3C160,139,320,85,480,106.7C640,128,800,224,960,224C1120,224,1280,128,1360,80L1440,32L1440,320L1360,320C1280,320,1120,320,960,320C800,320,640,320,480,320C320,320,160,320,80,320L0,320Z'%3E%3C/path%3E%3Cpath fill='%23070d12' fill-opacity='0.8' d='M0,256L120,224C240,192,480,128,720,149.3C960,171,1200,277,1320,330.7L1440,384L1440,320L1320,320C1200,320,960,320,720,320C480,320,240,320,120,320L0,320Z'%3E%3C/path%3E%3C/svg%3E");
}

.container { width: 100%; max-width: 1160px; position: relative; z-index: 1; margin: 0 auto; }
.container-wide { max-width: 1280px; }

::selection { background: rgba(13, 148, 136, 0.4); color: #fff; }

/* --------------------------------------------------------------- brand --- */

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.brand-logo {
  width: 44px; height: 44px; flex: none;
  background: linear-gradient(135deg, #0d9488 0%, #0284c7 50%, #f59e0b 100%);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 25px rgba(13, 148, 136, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.brand-text h1, .brand-text .brand-name {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.1;
  /* The name must never wrap — "T-Forward" breaking at the hyphen looked like
     two separate words stacked on top of each other on a phone. */
  white-space: nowrap;
  background: linear-gradient(135deg, #ffffff 30%, var(--sky-blue) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand-text span.brand-tag {
  display: block; white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.8px; color: var(--aspen-gold);
}

/* ------------------------------------------------------------ app chrome -- */

header.app-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.user-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-pill {
  font-size: 13px; color: var(--text-muted); background: rgba(255, 255, 255, 0.04);
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--card-border);
  display: flex; align-items: center; gap: 8px;
}
.user-dot { width: 7px; height: 7px; background: var(--spruce); border-radius: 50%; box-shadow: 0 0 8px var(--spruce); }

.nav-btn {
  font-family: var(--font-ui);
  color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: var(--r-sm); border: 1px solid var(--card-border);
  transition: all 0.2s; background: rgba(255, 255, 255, 0.03); cursor: pointer;
}
.nav-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
.nav-btn.active { background: rgba(13, 148, 136, 0.2); border-color: var(--spruce); color: var(--spruce-bright); }
.nav-btn.admin-gold { color: var(--aspen-gold); border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.08); }
.nav-btn.admin-gold:hover { background: rgba(245, 158, 11, 0.2); border-color: var(--aspen-gold); }
.nav-btn.logout:hover { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.08); }

/* ------------------------------------------------------------ containers -- */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 14px; padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}
.stat-label {
  font-family: var(--font-ui);
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 4px;
}
.stat-value { font-size: 26px; font-weight: 800; color: #fff; font-family: var(--font-mono); }

.glass-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: var(--r-lg); padding: 28px; margin-bottom: 26px;
  box-shadow: var(--shadow-card); transition: border-color 0.2s;
}
.glass-card:hover { border-color: var(--card-border-hover); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 14px; flex-wrap: wrap; }
.card-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; letter-spacing: 0.4px; color: #fff;
  display: flex; align-items: center; gap: 10px;
}
.card-sub { font-size: 13px; color: var(--text-muted); margin-top: -12px; margin-bottom: 20px; }

/* ---------------------------------------------------------------- forms --- */

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-row-top { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row-top { grid-template-columns: 1fr; } }

.input-group label, .field-label {
  font-family: var(--font-ui);
  display: block; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 6px;
}
.field-hint { font-size: 11px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }

input[type="text"], input[type="url"], input[type="email"],
input[type="password"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%; background: var(--field-bg); border: 1px solid var(--card-border);
  color: var(--text); padding: 11px 14px; border-radius: var(--r-md);
  font-size: 14px; font-family: inherit; transition: all 0.18s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
select {
  font-family: var(--font-ui); font-weight: 600; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
input[type="file"] {
  width: 100%; background: var(--field-bg); border: 1px solid var(--card-border);
  color: var(--text-muted); padding: 9px 12px; border-radius: var(--r-md);
  font-size: 13px; font-family: inherit; cursor: pointer;
}
input[type="file"]::file-selector-button {
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  background: rgba(255, 255, 255, 0.07); color: var(--text); cursor: pointer;
  border: 1px solid var(--card-border); border-radius: var(--r-sm);
  padding: 6px 12px; margin-right: 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--spruce);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25);
  background: rgba(7, 13, 18, 0.95);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

/* Visible keyboard focus everywhere, without a ring on mouse clicks. */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--spruce-bright); outline-offset: 2px; border-radius: 4px;
}

/* --------------------------------------------------------------- buttons -- */

.btn-create, .btn-primary {
  font-family: var(--font-ui);
  background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
  color: white; border: none; padding: 12px 28px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 700; letter-spacing: 0.3px; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
  box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; line-height: 1.2;
}
.btn-create { height: 44px; }
.btn-create:hover, .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(13, 148, 136, 0.45); }
.btn-create:disabled, .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-gold {
  font-family: var(--font-ui);
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1c1207; border: none; padding: 12px 28px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 800; cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(245, 158, 11, 0.45); }

.btn-ghost {
  font-family: var(--font-ui);
  background: rgba(255, 255, 255, 0.04); color: var(--text);
  border: 1px solid var(--card-border); padding: 11px 22px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.22); }

.action-btn {
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--card-border);
  color: var(--text-muted); padding: 6px 11px; border-radius: var(--r-sm);
  text-decoration: none; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: var(--font-ui);
  display: inline-flex; align-items: center; gap: 5px;
}
.action-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.action-btn.edit-btn { background: rgba(56, 189, 248, 0.1); color: var(--sky-blue); border-color: rgba(56, 189, 248, 0.25); }
.action-btn.edit-btn:hover { background: rgba(56, 189, 248, 0.2); border-color: var(--sky-blue); color: #fff; }
.delete-btn {
  background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger); padding: 6px 11px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s;
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
}
.delete-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-group { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* --------------------------------------------------------------- tables --- */

.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  font-family: var(--font-ui);
  color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; padding: 14px 16px; border-bottom: 1px solid var(--card-border);
  text-align: left; white-space: nowrap;
}
td { padding: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); vertical-align: middle; font-size: 14px; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
.row-title { font-weight: 700; color: #fff; font-size: 14px; margin-bottom: 2px; }
.row-date { font-size: 12px; color: var(--text-dim); }
.logo-indicator {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
  color: var(--aspen-gold); background: rgba(245, 158, 11, 0.1);
  padding: 2px 6px; border-radius: 4px; margin-top: 4px;
}
.owner-tag { font-size: 11px; color: var(--aspen-gold); font-weight: 600; }
.type-chip {
  display: inline-block; font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; padding: 2px 7px; border-radius: 4px;
  background: rgba(56, 189, 248, 0.12); color: var(--sky-blue);
  border: 1px solid rgba(56, 189, 248, 0.25); margin-top: 5px;
}
.type-chip.dynamic { background: rgba(13, 148, 136, 0.14); color: var(--spruce-bright); border-color: rgba(13, 148, 136, 0.3); }

.slug-badge {
  background: rgba(13, 148, 136, 0.12); color: var(--spruce-bright);
  border: 1px solid rgba(13, 148, 136, 0.28); padding: 4px 10px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: all 0.2s;
}
.slug-badge:hover { background: rgba(13, 148, 136, 0.28); transform: translateY(-1px); }
.target-link {
  color: var(--sky-blue); text-decoration: none; max-width: 240px; display: inline-block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 13px; vertical-align: bottom;
}
.target-link:hover { text-decoration: underline; }
.static-payload {
  color: var(--text-muted); font-family: var(--font-mono); font-size: 12px;
  max-width: 240px; display: inline-block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.scan-pill {
  background: rgba(245, 158, 11, 0.1); color: var(--aspen-gold);
  border: 1px solid rgba(245, 158, 11, 0.25); padding: 4px 12px; border-radius: 12px;
  font-weight: 700; font-size: 13px; font-family: var(--font-mono);
}
.scan-pill.muted { background: rgba(255, 255, 255, 0.04); color: var(--text-dim); border-color: var(--card-border); }
.empty-row { text-align: center; padding: 36px; color: var(--text-dim); }

/* ----------------------------------------------------------------- auth --- */

.auth-box { max-width: 430px; margin: 40px auto; }
.error-banner {
  background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5; padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 20px; font-size: 13px;
}
.notice-banner {
  background: rgba(13, 148, 136, 0.12); border: 1px solid rgba(13, 148, 136, 0.3);
  color: var(--spruce-bright); padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 20px; font-size: 13px;
}

/* --------------------------------------------------------------- modals --- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(3, 7, 10, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--card-solid); border: 1px solid var(--card-border);
  padding: 32px; border-radius: 22px; text-align: center; max-width: 400px; width: 100%;
  box-shadow: var(--shadow-pop); position: relative;
}
.modal-card img {
  width: 240px; height: 240px; border-radius: 14px; margin: 18px auto;
  background: #fff; padding: 12px; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); display: block;
}
.modal-close {
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--card-border); color: white;
  padding: 9px 22px; border-radius: var(--r-md); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: var(--font-ui);
}
.modal-close:hover { background: rgba(255, 255, 255, 0.15); }
.edit-modal-card {
  background: var(--card-solid); border: 1px solid var(--card-border);
  padding: 28px; border-radius: 20px; max-width: 520px; width: 100%; text-align: left;
  box-shadow: var(--shadow-pop); margin: auto;
}
.modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 18px; }
.tag-warning { font-size: 11px; color: var(--aspen-gold); margin-top: 5px; display: block; line-height: 1.5; }

/* -------------------------------------------------------------- utility --- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.gold { color: var(--aspen-gold); }
.teal { color: var(--spruce-bright); }
.flex-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Keep the download trio on one line; the table scrolls horizontally if the
   viewport cannot fit it, which reads better than a ragged two-row wrap. */
td .btn-group { flex-wrap: nowrap; }
td .btn-group .action-btn, td .btn-group .delete-btn { white-space: nowrap; }


/* The brand lock-up scales down rather than wrapping on narrow screens. */
@media (max-width: 460px) {
  .brand { gap: 10px; }
  .brand-logo { width: 38px; height: 38px; }
  .brand-text h1, .brand-text .brand-name { font-size: 19px; letter-spacing: 0.2px; }
  .brand-text span.brand-tag { font-size: 7.5px; letter-spacing: 0.2px; }
}
@media (max-width: 380px) {
  .brand-text h1, .brand-text .brand-name { font-size: 17px; }
}
