/* ============================================================
   FitForge — base.css
   CSS Reset, Global Defaults, Body, Scrollbars
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  position: relative;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }

/* ── Selection ── */
::selection {
  background: rgba(245, 130, 31, 0.25);
  color: var(--text-primary);
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--brand-amber);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* ── Typography Base ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl)); }
h2 { font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl)); }
h3 { font-size: clamp(var(--text-xl), 3vw, var(--text-2xl)); }
h4 { font-size: var(--text-xl); font-family: var(--font-body); font-weight: var(--weight-semibold); }
h5 { font-size: var(--text-lg); font-family: var(--font-body); font-weight: var(--weight-semibold); }
h6 { font-size: var(--text-base); font-family: var(--font-body); font-weight: var(--weight-medium); }

p { color: var(--text-secondary); line-height: var(--leading-relaxed); }

a {
  color: var(--brand-amber);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-smooth);
}
a:hover { color: var(--brand-amber2); }

/* ── Form Resets ── */
button, input, select, textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
  border: none;
  outline: none;
  background: none;
}
button { cursor: pointer; }
input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

/* ── Images ── */
img, svg, video { display: block; max-width: 100%; }

/* ── Lists ── */
ul, ol { list-style: none; }

/* ── Background Mesh ── */
.bg-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  will-change: transform;
}

.bg-orb--1 {
  width: min(700px, 70vw);
  height: min(700px, 70vw);
  background: radial-gradient(circle, var(--brand-amber), transparent 70%);
  top: -15%;
  left: -10%;
  animation: orb-drift-1 20s ease-in-out infinite;
}

.bg-orb--2 {
  width: min(500px, 50vw);
  height: min(500px, 50vw);
  background: radial-gradient(circle, var(--accent-purple), transparent 70%);
  top: 35%;
  right: -10%;
  animation: orb-drift-2 26s ease-in-out infinite 4s;
}

.bg-orb--3 {
  width: min(400px, 40vw);
  height: min(400px, 40vw);
  background: radial-gradient(circle, var(--accent-cyan), transparent 70%);
  bottom: -10%;
  left: 25%;
  opacity: 0.07;
  animation: orb-drift-3 32s ease-in-out infinite 8s;
}

@keyframes orb-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(40px, -30px) scale(1.05); }
  66%       { transform: translate(-20px, 25px) scale(0.95); }
}
@keyframes orb-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-35px, 20px) scale(1.08); }
  70%       { transform: translate(25px, -15px) scale(0.96); }
}
@keyframes orb-drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(30px, -20px) scale(1.1); }
}

/* ── Grain Overlay ── */
.bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── App Root ── */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ── Page View ── */
.page-view {
  display: none;
  animation: page-in var(--duration-slow) var(--ease-out) both;
}
.page-view.active {
  display: block;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading Screen ── */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-supreme);
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  transition: opacity var(--duration-slower) var(--ease-smooth);
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-logo {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.03em;
}
.loading-logo span { color: var(--brand-amber); }
.loading-bar {
  width: 120px;
  height: 2px;
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-amber), var(--brand-gold));
  border-radius: var(--radius-full);
  animation: load-fill 1.5s var(--ease-smooth) forwards;
}
@keyframes load-fill {
  to { width: 100%; }
}

/* ── Utility Classes ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.w-full { width: 100%; }
.text-center { text-align: center; }

.label-mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}

/* ── Hidden utility (toggled by auth.js) ── */
.hidden { display: none !important; }

/* ── Auth screen full-page ── */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-supreme);
  overflow-y: auto;
}
#auth-screen.hidden { display: none !important; }
