/* =============================================================
   GMFJ PWA — App shell + base components
   Mobile-first. Desktop renders the same canvas centred at
   --app-max so the prototype always reads as a phone app.
   ============================================================= */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fnt-body);
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-soft);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--font-display-weight);
  color: var(--text-strong);
  line-height: 1.1;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fnt-h1); }
h2 { font-size: var(--fnt-h2); }
h3 { font-size: var(--fnt-h3); }
h4 { font-size: var(--fnt-h4); }
p { margin: 0 0 var(--space-3); }
a { color: var(--indigo-300); text-decoration: none; }
img { max-width: 100%; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }

.muted { color: var(--text-muted); }
.small { font-size: var(--fnt-small); }
.center { text-align: center; }
.display { font-family: var(--font-display); font-weight: var(--font-display-weight); }
/* Any element opting into the display font (incl. inline styles) renders bold */
[style*="--font-display"] { font-weight: var(--font-display-weight); }
.stack > * + * { margin-top: var(--space-4); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------
   App shell: phone-shaped canvas centred on desktop
   --------------------------------------------------------------- */
.app {
  position: relative;
  width: 100%;
  max-width: var(--app-max);
  height: 100dvh; /* fixed frame height so .app-main scrolls internally and the bottom nav stays pinned */
  margin: 0 auto;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.app-header.is-hidden { display: none; }

/* Brand logo (real GMFJ mark) */
.logo { display: inline-flex; align-items: center; }
.logo img { height: 1.6rem; width: auto; display: block; }
.hero .logo img, .logo.on-dark img { height: 1.9rem; }

/* Logo theme-swap: dark-text mark on light UI, white mark on dark UI */
.logo .logo-on-dark { display: none; }
:root[data-theme="dark"] .logo .logo-on-light { display: none; }
:root[data-theme="dark"] .logo .logo-on-dark { display: block; }

/* Legacy text wordmark — kept as a fallback only */
.wordmark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  display: inline-flex;
  align-items: baseline;
}
.wordmark b { color: var(--deep-pink-200); font-weight: 400; }
.wordmark .accent { color: var(--red-200); }

.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  width: 2.25rem; height: 2.25rem;
  display: inline-grid; place-items: center;
  border: none; border-radius: var(--radius-pill);
  background: var(--surface-alt); color: var(--text-strong);
  position: relative;
}
.icon-btn .material-icons { font-size: 1.25rem; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red-200); border: 2px solid var(--surface);
}

/* ---- Main view region ---- */
.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--bottomnav-h) + var(--space-5));
}
.view-pad { padding: var(--space-5) var(--space-4); }
.app-main.no-nav { padding-bottom: var(--space-5); }

/* page enter animation */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.app-main > .view { animation: viewIn 0.22s ease both; }
@media (prefers-reduced-motion: reduce) { .app-main > .view { animation: none; } }

/* ---- Bottom navigation ---- */
.bottom-nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--bottomnav-h);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav.is-hidden { display: none; }
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.bottom-nav a .material-icons { font-size: 1.4rem; }
.bottom-nav a.active { color: var(--deep-pink-200); }
.bottom-nav a.cta {
  color: #fff;
}
.bottom-nav a.cta .material-icons {
  background: var(--brand-gradient);
  color: #fff;
  width: 2.6rem; height: 2.6rem;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  margin-top: -1.1rem;
  box-shadow: var(--shadow-md);
}
.bottom-nav a.cta span:last-child { color: var(--deep-pink-200); }

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 0.8rem 1.25rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid transparent;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 1rem 1.5rem; font-size: 1.05rem; }
.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-md); }
.btn-cta { background: var(--brand-gradient-warm); color: #fff; box-shadow: var(--shadow-md); }
.btn-dark { background: var(--primary-100); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--text-strong); }
.btn-ghost { background: var(--surface-alt); color: var(--text-strong); }
.btn .material-icons { font-size: 1.2rem; }

/* ---- Provider (social login) buttons ---- */
.btn-provider {
  width: 100%; display: flex; align-items: center; gap: var(--space-3);
  padding: 0.85rem 1rem; border: 1.5px solid var(--line);
  border-radius: var(--radius-pill); background: var(--surface);
  color: var(--text-strong); font-family: var(--font-body); font-weight: 700; font-size: 0.95rem;
  transition: box-shadow 0.15s ease, transform 0.08s ease;
}
.btn-provider:hover { box-shadow: var(--shadow-md); }
.btn-provider:active { transform: translateY(1px); }
.btn-provider.is-loading { opacity: 0.7; pointer-events: none; }
.btn-provider .prov-ic { width: 24px; display: inline-grid; place-items: center; flex: none; }
.btn-provider .label { flex: 1; text-align: center; margin-right: 24px; }
.badge-fb { width: 22px; height: 22px; border-radius: 50%; background: #1877f2; color: #fff; display: grid; place-items: center; font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 1rem; line-height: 1; }
.badge-ucas { background: #e6007e; color: #fff; border-radius: 5px; font-size: 0.5rem; font-weight: 800; letter-spacing: 0.02em; padding: 2px 4px; line-height: 1; }

.or-divider { display: flex; align-items: center; gap: var(--space-3); color: var(--text-muted); font-size: var(--fnt-small); font-weight: 700; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------------------------------------------------------------
   Cards, chips, pills
   --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.card-tap { cursor: pointer; transition: box-shadow 0.15s ease, transform 0.08s ease; }
.card-tap:active { transform: scale(0.995); }
.card-tap:hover { box-shadow: var(--shadow-md); }

.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: 1.5px solid var(--line);
  color: var(--text-strong);
  font-size: var(--fnt-small); font-weight: 700;
  white-space: nowrap;
  user-select: none;
}
.chip .material-icons { font-size: 1rem; }
.chip.is-selected { background: var(--soft-blue-200); border-color: var(--indigo-300); color: var(--indigo-300); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-scroll { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem; border-radius: var(--radius-pill);
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.pill-applied   { background: var(--soft-blue-200); color: var(--indigo-300); }
.pill-reviewing { background: #fdeccb; color: #9a6a12; }
.pill-interview { background: #e6d6f3; color: var(--dark-purple-400); }
.pill-offer     { background: #d7f0e2; color: #1f7a4d; }
.pill-rejected  { background: #f6dcd4; color: var(--red-200); }
.pill-withdrawn { background: var(--surface-alt); color: var(--text-muted); }

.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-3); color: var(--text-muted); font-size: var(--fnt-small); }
.meta-row span { display: inline-flex; align-items: center; gap: 0.3rem; }
.meta-row .material-icons { font-size: 1rem; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-3); }
.section-head h2, .section-head h3 { margin: 0; }
.section-head a { font-size: var(--fnt-small); font-weight: 700; }

/* ---- Form fields ---- */
.field { margin-bottom: var(--space-4); }
.field label { display: block; font-weight: 700; color: var(--text-strong); margin-bottom: var(--space-3); font-size: var(--fnt-small); }
.input, .textarea, .select {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font: inherit; color: var(--text-strong);
  background: var(--surface);
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--indigo-300); box-shadow: 0 0 0 3px rgba(60,95,156,0.15); }
.textarea { min-height: 6rem; resize: vertical; }

.search-bar { display: flex; align-items: center; gap: var(--space-2); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-pill); padding: 0.2rem 0.4rem 0.2rem 1rem; box-shadow: var(--shadow-sm); }
.search-bar .material-icons { color: var(--text-muted); }
.search-bar input { flex: 1; border: none; background: transparent; font: inherit; padding: 0.6rem 0; }
.search-bar input:focus { outline: none; }
.search-bar .btn { padding: 0.6rem 1rem; }

/* ---- Filter row (jobs search): pill-shaped selects ---- */
.filter-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.select-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius-pill); padding: 0 0.5rem 0 0.85rem;
  box-shadow: var(--shadow-sm); min-width: 0; flex: 1 1 auto;
}
.select-pill .material-icons { font-size: 1.1rem; color: var(--text-muted); flex: none; }
.select-pill select {
  appearance: none; -webkit-appearance: none;
  border: none; background: transparent; font: inherit; font-weight: 700;
  color: var(--text-strong); padding: 0.6rem 1.6rem 0.6rem 0;
  width: 100%; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b6e7c' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 0.1rem center;
}
.select-pill select:focus { outline: none; }
:root[data-theme="dark"] .select-pill select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238b91a7' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
}
.filter-row .chip { flex: none; }

/* ---- Skeleton loaders ---- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-soft); border-radius: var(--radius); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-line { height: 0.8rem; margin-bottom: 0.5rem; }
.sk-line.w-60 { width: 60%; } .sk-line.w-40 { width: 40%; } .sk-line.w-80 { width: 80%; }
.sk-card { height: 7.5rem; margin-bottom: var(--space-3); border-radius: var(--radius-lg); }

/* ---- Empty / toast ---- */
.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-muted); }
.empty .material-icons { font-size: 3rem; color: var(--soft-blue-200); }

.toast-wrap { position: absolute; left: 0; right: 0; bottom: calc(var(--bottomnav-h) + 1rem); display: flex; flex-direction: column; align-items: center; gap: 0.5rem; z-index: 60; pointer-events: none; }
.toast { background: var(--primary-100); color: #fff; padding: 0.7rem 1.1rem; border-radius: var(--radius-pill); font-weight: 700; font-size: var(--fnt-small); box-shadow: var(--shadow-lg); animation: viewIn 0.2s ease both; }

/* ---- Cookie / local storage consent banner ---- */
.consent-banner {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 65;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  animation: sheetUp 0.25s cubic-bezier(.2,.8,.2,1) both;
}
.consent-actions { display: flex; gap: var(--space-3); margin-top: var(--space-3); }
.consent-actions .btn { flex: 1; }

/* ---- Hero (onboarding / sign-in) ---- */
.hero {
  background: var(--brand-gradient);
  color: #fff;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  padding: var(--space-7) var(--space-5) var(--space-6);
  position: relative;
  overflow: hidden;
}
.hero::after { content: ""; position: absolute; width: 220px; height: 220px; right: -60px; top: -60px; background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%); }
.hero h1, .hero h2 { color: #fff; }
.hero .display-xl { font-family: var(--font-display); font-weight: var(--font-display-weight); font-size: var(--fnt-display-1); line-height: 1; margin: 0 0 var(--space-3); }
.hero .lede { color: rgba(255,255,255,0.9); font-size: 1.05rem; max-width: 28ch; }

/* offline banner */
.offline-banner { display: none; background: var(--primary-100); color: #fff; text-align: center; font-size: var(--fnt-small); font-weight: 700; padding: 0.4rem; }
body.is-offline .offline-banner { display: block; }

@media (min-width: 540px) {
  body { padding: var(--space-5) 0; }
  .app { height: calc(100dvh - 2 * var(--space-5)); border-radius: var(--radius-xl); }
}
