/* ==========================================================================
   RateMyChance — Design System
   Primary colour: Electric Blue #2563EB (chosen from the brief's pastel range;
   passes WCAG AA on white, applied consistently throughout)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* Colours */
  --bg: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #555555;
  --text-helper: #888888;
  --border: #E0E0E0;
  --error: #D93025;
  --success: #1E7E34;

  --primary: #2563EB;
  --primary-hover: #1D4FD7;
  --primary-active: #1A45BD;
  --primary-tint: rgba(37, 99, 235, 0.10);
  --primary-tint-strong: rgba(37, 99, 235, 0.16);
  --secondary-bg: #EEF3FE;        /* light tint of primary for secondary CTA */
  --secondary-bg-hover: #E2EBFD;
  --locked-bg: #F5F5F5;
  --warm-tint: #FBF7F2;           /* anxiety-reset warm off-white */
  --section-tint: #F7F9FC;        /* light closing-CTA / school-insight tint */

  --amber: #C77700;

  /* Type */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Radii & shadow */
  --radius-btn: 8px;
  --radius-input: 8px;
  --radius-card: 12px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --shadow-card-hover: 0 2px 4px rgba(16, 24, 40, 0.06), 0 8px 28px rgba(16, 24, 40, 0.08);
  --shadow-pop: 0 8px 30px rgba(16, 24, 40, 0.12);

  /* Layout */
  --maxw: 1200px;
  --btn-h: 52px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid rgba(37,99,235,0.45); outline-offset: 2px; border-radius: 4px; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { margin: 0; font-weight: 800; line-height: 1.12; letter-spacing: -0.02em; color: var(--text-primary); }
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
p { margin: 0; }
.text-secondary { color: var(--text-secondary); }
.text-helper { color: var(--text-helper); }
.mono { font-family: var(--font-mono); }

@media (min-width: 768px) {
  h1 { font-size: 48px; }
  h2 { font-size: 36px; }
  h3 { font-size: 24px; }
}

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { padding: 48px 0; }
@media (min-width: 768px) { .section { padding: 80px 0; } .container { padding: 0 40px; } }
.center { text-align: center; }
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }

/* ---------- Cookie consent banner ---------- */
.consent-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1000;
  margin: 0 auto; max-width: 680px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  background: #FFFFFF; border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop); padding: 14px 18px;
}
.consent-text { font-size: 14px; line-height: 1.5; color: var(--text-secondary); flex: 1 1 280px; }
.consent-actions { display: flex; gap: 8px; margin-left: auto; }
.consent-btn { min-height: 40px; padding: 0 18px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--btn-h); padding: 0 28px;
  border-radius: var(--radius-btn); border: 1px solid transparent;
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  text-decoration: none; transition: background .16s ease, color .16s ease, border-color .16s ease, transform .06s ease, box-shadow .16s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-secondary { background: var(--secondary-bg); color: var(--primary); border-color: transparent; }
.btn-secondary:hover { background: var(--secondary-bg-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: #FAFAFA; color: var(--text-primary); }
.btn-lg { min-height: 58px; font-size: 17px; padding: 0 34px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] {
  background: #EDEDED; color: #AAAAAA; cursor: not-allowed; border-color: transparent;
}
.btn[disabled]:active { transform: none; }
.btn-cta { width: 100%; }
@media (min-width: 768px) {
  .btn-cta { width: 280px; }
}

/* ---------- Cards ---------- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 24px; box-shadow: var(--shadow-card);
}
@media (min-width: 768px) { .card { padding: 32px; } }

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 18px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text-secondary); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .14s ease; user-select: none;
}
.pill:hover { border-color: #C9C9C9; color: var(--text-primary); }
.pill[aria-pressed="true"], .pill.selected {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 24px; }
.field-label { display: block; font-size: 15px; font-weight: 700; margin-bottom: 7px; color: var(--text-primary); line-height: 1.4; text-wrap: pretty; overflow-wrap: break-word; }
.field-label .req { color: var(--primary); font-weight: 700; }
.field-helper { font-size: 13px; color: var(--text-helper); margin: 0 0 9px; line-height: 1.5; }
.field-nudge { font-size: 13px; color: var(--primary); margin-top: 8px; font-weight: 500; }

.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: 16px; color: var(--text-primary);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-input);
  padding: 0 14px; transition: border-color .14s ease, box-shadow .14s ease;
  -webkit-appearance: none; appearance: none;
}
.input, .select { height: 48px; }
.textarea { min-height: 96px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: #B0B0B0; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.14);
}
.input-wrap { position: relative; }
.input-wrap .check {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--success); opacity: 0; transition: opacity .15s ease;
  pointer-events: none;
}
.field.valid .input-wrap .check { opacity: 1; }
.field.valid .input { padding-right: 40px; }

/* error state */
.field.error .input, .field.error .select, .field.error .textarea,
.field.error .dropdown-trigger { border-color: var(--error); }
.field.error .input:focus, .field.error .textarea:focus { box-shadow: 0 0 0 3px rgba(217,48,37,0.14); }
.field-error { display: none; color: var(--error); font-size: 13px; margin-top: 6px; line-height: 1.45; }
.field.error .field-error { display: block; }

/* select with custom chevron */
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
  cursor: pointer;
}

/* char counter */
.counter-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 6px; }
.char-counter { font-size: 12px; color: var(--text-helper); font-family: var(--font-mono); white-space: nowrap; }
.char-counter.amber { color: var(--amber); }
.char-counter.red { color: var(--error); }

/* ---------- Searchable dropdown ---------- */
.dropdown { position: relative; }
.dropdown-trigger {
  width: 100%; height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-input);
  padding: 0 14px; font-size: 16px; color: var(--text-primary); text-align: left;
}
.dropdown-trigger .placeholder { color: #B0B0B0; }
.dropdown-trigger[disabled] { background: #F5F5F5; color: #AAA; cursor: not-allowed; }
.dropdown-trigger .chev { width: 14px; height: 9px; flex: none; }
.dropdown-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-pop);
  overflow: hidden; display: none;
}
.dropdown.open .dropdown-panel { display: block; }
.dropdown.open .dropdown-trigger { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.14); }
.dropdown-search { padding: 10px; border-bottom: 1px solid var(--border); }
.dropdown-search input {
  width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 7px; padding: 0 12px;
  font-family: inherit; font-size: 15px;
}
.dropdown-search input:focus { outline: none; border-color: var(--primary); }
.dropdown-list { max-height: 240px; overflow-y: auto; }
.dropdown-option {
  padding: 11px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px;
}
.dropdown-option:hover, .dropdown-option.active { background: var(--primary-tint); }
.dropdown-option .flag { font-size: 18px; line-height: 1; }
.dropdown-empty { padding: 16px 14px; color: var(--text-helper); font-size: 14px; }

/* ---------- Callout box ---------- */
.callout {
  background: var(--primary-tint); border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0; padding: 16px 18px; color: var(--text-primary);
  font-size: 15px; line-height: 1.6;
}

/* ---------- Country tile grid ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 600px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 20px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-card);
  background: #fff; cursor: pointer; transition: all .14s ease; text-align: center;
}
.tile:hover { border-color: #C2D2F7; background: #FCFDFF; }
.tile .tile-code {
  width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary);
  font-family: var(--font-mono); font-weight: 700; font-size: 15px; letter-spacing: 0.03em;
  transition: background .14s ease, color .14s ease;
}
.tile .tile-name { font-size: 15px; font-weight: 700; }
.tile[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); }
.tile[aria-pressed="true"] .tile-code { background: var(--primary); color: #fff; }
.tile[aria-pressed="true"] .tile-name { color: var(--primary); }

/* ---------- Tooltip ---------- */
.tip-wrap { position: relative; display: inline-flex; }
.tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: #1A1A1A; color: #fff; font-size: 12.5px; font-weight: 500; line-height: 1.4;
  padding: 8px 12px; border-radius: 7px; width: max-content; max-width: 240px;
  opacity: 0; visibility: hidden; transition: opacity .14s ease; pointer-events: none; z-index: 50;
}
.tip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #1A1A1A; }
.tip-wrap:hover .tip { opacity: 1; visibility: visible; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.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;
}
.link-btn {
  background: none; border: none; color: var(--primary); font-size: 14px; font-weight: 600;
  padding: 4px 0; cursor: pointer; white-space: nowrap; text-align: left;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Brand lockup (shared header) ---------- */
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-lockup:hover { text-decoration: none; }
.brand-lockup .brand-icon { width: 30px; height: 30px; flex: none; }
.brand-lockup .brand-name { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); }
.brand-lockup .brand-name .accent { color: var(--primary); }

/* fade-in animation for progressive reveal */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeUp .3s ease-in both; }
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  html { scroll-behavior: auto; }
}
