/* ============================================================
   STEMMA — main.css
   Mobile-first. Max content width 480px (phone).
   Design tokens → components → layout → utilities
   ============================================================ */

/* ── Design tokens ── */
:root {
  /* ── Core palette ── */
  --color-primary:       #1B2541;   /* Navy/dark blue */
  --color-primary-light: #2D6A4F;   /* Hover states, secondary emphasis */
  --color-primary-dark:  #14331C;   /* Pressed states */
  --color-accent:        #E8652E;   /* CTA buttons, streak, active nav (orange) */
  --color-accent-light:  #FF8C5A;   /* Accent hover states */
  --color-bg:            #FFF8F0;   /* Page background (warm cream) */
  --color-surface:       #FFFFFF;   /* Card backgrounds */
  --color-surface-2:     #EAE8E0;   /* Secondary surfaces, unfilled progress */
  --color-text:          #2B2B2B;   /* Primary text (dark charcoal) */
  --color-text-muted:    #666666;   /* Secondary text, labels, captions */
  --color-border:        #E6E4DD;   /* Card borders, dividers */

  /* ── Semantic colors ── */
  --color-success:       #15803D;
  --color-success-bg:    #F0FDF4;
  --color-error:         #B91C1C;
  --color-error-bg:      #FEF2F2;
  --color-warning:       #B45309;
  --color-warning-bg:    #FFFBEB;
  --color-info:          #1D4ED8;
  --color-info-bg:       #EFF6FF;

  /* ── Feature-specific colors ── */
  --color-mastery-learning:    #E8A838;   /* Mastery bar: "Learning" (amber/gold) */
  --color-mastery-familiar:    #3B7DD8;   /* Mastery bar: "Familiar" (blue) */
  --color-mastery-mastered:    #38B865;   /* Mastery bar: "Mastered" (green) */
  --color-streak:              #E8652E;   /* Streak widget, fire emoji backgrounds */
  --color-xp-green:            #C8E8D0;   /* XP card background (soft mint) */
  --color-rank-blue:           #C8D8F0;   /* Rank card background (soft blue) */
  --color-achievement-green:   #38B865;   /* Achievement badge: earned (green) */
  --color-achievement-purple:  #D8C8F0;   /* Achievement badge: earned (lavender) */
  --color-achievement-locked:  #D0D0D0;   /* Achievement badge: locked (gray) */
  --color-logout:              #FF6B6B;   /* Logout button (coral red) */
  --color-chapter-active:      #E8F5E8;   /* Active chapter card tint (pale green) */
  --color-chapter-mastered:    #F0FDF4;   /* Mastered chapter card tint */

  /* ── Widget card tints ── */
  --color-tint-indigo:   #e0e7ff;   /* Streak card, in-progress chapters */
  --color-tint-emerald:  #d1fae5;   /* Chapters stat card, mastered chapters */
  --color-tint-blue:     #dbeafe;   /* Mastery stat card */
  --color-tint-orange:   #fff7ed;   /* Weekly progress card */
  --color-tint-amber:    #fef3c7;   /* Up Next icon box */

  /* ── Neo-brutalism ── */
  --color-border-dark:   #1e1e1e;   /* Hard border for neo-brutalism components */

  /* ── Typography ── */
  --font-display: 'Public Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

  /* ── Radii ── */
  --radius:     12px;
  --radius-sm:  6px;
  --radius-lg:  20px;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(45, 40, 35, 0.05);
  --shadow:    0 4px 12px rgba(45, 40, 35, 0.08);
  --shadow-lg: 0 12px 24px rgba(45, 40, 35, 0.12);

  /* ── Layout ── */
  --nav-height: 64px;
  --transition: 150ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-display);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
input, textarea { font: inherit; }

/* ── Layout ── */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
}
.container--with-nav {
  padding-bottom: calc(var(--nav-height) + 24px);
}

/* ── Flash messages ── */
.flash-messages {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 8px 16px 0;
  max-width: 480px;
  margin: 0 auto;
}
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}
.flash--error   { background: var(--color-error-bg);   color: var(--color-error); }
.flash--success { background: var(--color-success-bg); color: var(--color-success); }
.flash--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.flash--info    { background: var(--color-info-bg);    color: var(--color-info); }

/* ── Bottom navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-bg);
  border-top: 2px solid var(--color-border-dark);
  display: flex;
  align-items: stretch;
  z-index: 200;
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition);
  padding: 8px 0;
}
.bottom-nav__item:hover,
.bottom-nav__item--active {
  color: var(--color-accent);
  text-decoration: none;
}
.bottom-nav__icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), border var(--transition);
}
.bottom-nav__icon-wrap--active {
  background: rgba(232, 101, 46, 0.15);
  border: 1px solid var(--color-border-dark);
}
.bottom-nav__icon-wrap .material-symbols-outlined {
  font-size: 1.4rem;
  line-height: 1;
}
.bottom-nav__item--active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1;
}
.bottom-nav__label { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn--primary {
  background: var(--color-accent);
  color: #fff;
  width: 100%;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn--primary:hover { background: var(--color-accent-light); text-decoration: none; color: #fff; }
.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  border: 2px solid var(--color-text);
  font-weight: 700;
}
.btn--secondary:hover { background: var(--color-surface-2); text-decoration: none; color: var(--color-text); }
.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 0.9rem;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn--cta {
  background: var(--color-accent);
  color: #fff;
  width: 100%;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 18px 24px;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn--cta:hover { background: var(--color-accent-light); text-decoration: none; color: #fff; }

/* Inline chapter card CTA (auto-width, smaller) */
.btn--chapter-cta {
  background: var(--color-accent);
  color: #fff;
  width: auto;
  padding: 8px 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn--chapter-cta:hover { background: var(--color-accent-light); text-decoration: none; color: #fff; }
.btn--chapter-cta--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-border-dark);
}
.btn--chapter-cta--secondary:hover { background: var(--color-surface-2); text-decoration: none; color: var(--color-text); }
.btn--chapter-cta--disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  border: 2px solid #94a3b8;
}

/* Danger / Logout */
.btn--danger {
  background: var(--color-logout);
  color: #fff;
  width: 100%;
  border-radius: var(--radius);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.btn--danger:hover { opacity: 0.9; text-decoration: none; color: #fff; }

/* ── Form elements ── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}
.form-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 1rem;
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.15);
}
.form-input--error { border-color: var(--color-error); }
.form-input--success { border-color: var(--color-success); }
.form-error {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 4px;
}
.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.checkbox-row label {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* ── Cards ── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

/* ── Error screen ── */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 0;
  gap: 16px;
}
.error-screen__code {
  font-size: 4rem;
  font-weight: 800;
  color: var(--color-border);
  line-height: 1;
}
.error-screen__title {
  font-size: 1.5rem;
  font-weight: 700;
}
.error-screen__body {
  color: var(--color-text-muted);
  max-width: 280px;
}

/* ── Utility ── */
.text-muted   { color: var(--color-text-muted); }
.text-center  { text-align: center; }
.text-small   { font-size: 0.875rem; }
.font-serif   { font-family: var(--font-serif); }
.font-sans    { font-family: var(--font-sans); }
.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.mb-8  { margin-bottom: 32px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mb-0  { margin-bottom: 0; }

/* ── Neo-brutalism utilities ── */
.neo-brutalism {
  border: 2px solid var(--color-border-dark);
  box-shadow: 4px 4px 0px 0px var(--color-border-dark);
}
.neo-brutalism-sm {
  border: 2px solid var(--color-border-dark);
  box-shadow: 2px 2px 0px 0px var(--color-border-dark);
}
.neo-brutalism:active,
.neo-brutalism-sm:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

/* ── Section headers (— TITLE pattern) ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text);
  margin-bottom: 12px;
}
.section-header::before {
  content: '';
  width: 20px;
  height: 3px;
  background: var(--color-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Page title (h1 used across list, settings, etc.) ── */
.page-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-text);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

/* ── Dashboard page ── */
.dashboard-greeting {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}
.streak-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.practice-callout {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

/* ── Auth card (forgot/reset password) ── */
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* ── Settings / Profile page ── */
.settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}
.settings-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 24px;
}
.settings-logout {
  padding-bottom: 2rem;
}

/* ── Profile widgets (neo-brutalism redesign) ── */
.profile-widget {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
}

/* Profile section heading (matches the visual style of the original page h1) */
.profile-section-heading {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-text);
  margin-bottom: 20px;
  margin-top: 0;
}
h2.profile-section-heading {
  margin-top: 32px;
}

/* Profile field static value display */
.profile-field__value {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 4px;
}

/* Labeled input field card */
.profile-field {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.profile-field__label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.profile-field__input {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  padding: 0;
}
.profile-field__input--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.profile-field__hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ── Form row helpers ── */
.form-row--between {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}
.form-label--inline {
  margin-bottom: 0;
}
.link-underline {
  text-decoration: underline;
}

/* ── Auth screens ── */
.auth-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 48px 0 32px;
}
.auth-screen__brand {
  text-align: center;
  margin-bottom: 40px;
}
.brand {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0;
}
.brand__tagline {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.auth-form {
  display: flex;
  flex-direction: column;
}
.auth-screen__switch {
  color: var(--color-text-muted);
}

/* ── Dashboard stub ── */
.dashboard-stub {
  padding: 40px 0;
}
.dashboard-stub__greeting {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* ── SSO / OAuth buttons ── */
.sso-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.btn--sso {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  width: 100%;
  font-weight: 500;
  font-size: 0.95rem;
  justify-content: center;
  text-decoration: none;
  padding: 11px 16px;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.btn--sso:hover {
  background: var(--color-surface-2, #f5f0e8);
  text-decoration: none;
  color: var(--color-text);
}
.btn--sso-google:hover  { border-color: #4285F4; }
.btn--sso-facebook:hover { border-color: #1877F2; }

.sso-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* "or" divider between SSO buttons and email form */
.sso-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--color-text-muted, #888);
  font-size: 0.85rem;
}
.sso-divider::before,
.sso-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
