/* Finn English Placement Test — candidate UI (mobile-first) */
/* Finn CI typography: licensed fonts are served locally from assets/fonts/ (see fonts/README.txt); fallbacks otherwise. */
@font-face { font-family: "FC Friday"; src: url("fonts/FCFriday.woff2") format("woff2"), url("fonts/FCFriday.woff") format("woff"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Supermarket"; src: url("fonts/Supermarket.woff2") format("woff2"), url("fonts/Supermarket.woff") format("woff"); font-weight: 400 700; font-display: swap; }
:root {
  /* Finn CI colours */
  --navy: #151A5C;      /* Finn Navy: primary (headers, primary buttons, nav) */
  --navy-2: #252C7E;    /* hover shade of Finn Navy */
  --navy-soft: #ECEDF6;
  --yellow: #FFC316;    /* Finn Yellow: accent (bars, highlights, active) — never as text on white */
  --yellow-soft: #FFF3CC;
  --blue: #006AAF;      /* Finn Blue: secondary (links, info, secondary buttons) */
  --blue-soft: #E5F0F8;
  --ink: #1B1F3B;
  --muted: #555B70;
  --line: #D9DBE7;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --ok: #1E7B4F;
  --warn: #8A5A00;
  --bad: #B42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --font: "Supermarket", "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Tahoma", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "FC Friday", "Kanit", "Prompt", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
body.exam-app {
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  padding-bottom: var(--notice-h, 120px); /* = measured AI notice height (exam.js ResizeObserver) */
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; color: var(--navy); font-family: var(--font-display); font-weight: 700; }
a { color: var(--blue); }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .8em; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Top bar */
/* Top bar: white (the full-colour logo is only used on white), navy text, yellow accent line + timer bar. */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; color: var(--navy); box-shadow: 0 2px 6px rgba(0,0,0,.08); border-bottom: 3px solid var(--yellow); }
.topbar-inner { display: flex; align-items: center; gap: 10px; max-width: 1100px; margin: 0 auto; padding: 10px 16px; min-height: 48px; }
.logo { font-family: var(--font-display); font-weight: 800; letter-spacing: .12em; background: var(--yellow); color: var(--navy); border-radius: 6px; padding: 2px 8px; font-size: .85rem; }
.title { font-size: .95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { margin-left: auto; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.timebar { height: 8px; background: var(--navy-soft); }
.timebar-fill { height: 100%; width: 100%; background: var(--yellow); transform-origin: left center; transition: background-color .3s; }
.timebar-fill.low { background: #FF9F1A; }
.timebar-fill.critical { background: #FF6B5E; }

/* Layout */
.container { max-width: 760px; margin: 0 auto; padding: 16px; position: relative; z-index: 2; }
.container.wide { max-width: 1100px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 560px; margin: 10vh auto; }
.brand { font-family: var(--font-display); color: var(--navy); font-weight: 700; letter-spacing: .02em; margin-bottom: 8px; font-size: .9rem; text-transform: uppercase; }
.lead { font-size: 1.05rem; color: var(--muted); }
.landing { padding: 16px; }

/* Lists and info */
.steps { padding-left: 1.2em; margin: 0 0 1em; }
.steps li { margin-bottom: .45em; }
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.parts div { background: var(--navy-soft); border-radius: 8px; padding: 8px 10px; font-size: .9rem; }
.parts b { color: var(--navy); display: block; }
.consent { display: flex; gap: 12px; align-items: flex-start; background: #FBFCFE; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; cursor: pointer; }
.consent input { width: 22px; height: 22px; margin-top: 3px; flex: none; accent-color: var(--navy); }
.consent span { font-size: .95rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 22px; border-radius: 10px; border: 0; font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer; background: var(--navy); color: #fff; width: 100%; touch-action: manipulation; }
.btn:hover { background: var(--navy-2); }
.btn:disabled { background: #9A9DB8; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn:focus-visible, .opt:focus-visible, input:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* Item screen */
.section-label { border-left: 4px solid var(--yellow); display: inline-block; font-size: .85rem; font-weight: 700; color: var(--navy); background: var(--navy-soft); border-radius: 999px; padding: 3px 12px; margin-bottom: 10px; }
.section-label.practice { background: #FFF4DE; color: #8A5A00; }
.time-left { float: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: .95rem; }
.time-left.low { color: var(--bad); }
.passage { background: #FBFCFE; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 10px; padding: 14px 16px; max-height: 34vh; overflow-y: auto; -webkit-overflow-scrolling: touch; margin-bottom: 14px; font-size: 1.0625rem; line-height: 1.7; }
.passage p { margin: 0 0 .6em; }
.passage-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stem { font-size: 1.15rem; font-weight: 600; margin: 4px 0 16px; white-space: pre-line; }
.options { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font: inherit; font-size: 1.0625rem; color: var(--ink); cursor: pointer; touch-action: manipulation; transition: border-color .15s, background .15s; }
.opt:hover:not(:disabled) { border-color: var(--navy-2); background: #F7F9FD; }
.opt .letter { flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--navy-soft); color: var(--navy); font-weight: 800; font-size: .95rem; }
.opt.selected { border-color: var(--navy); background: var(--yellow-soft); }
.opt.selected .letter { background: var(--yellow); color: var(--navy); }
.opt:disabled { cursor: default; opacity: .85; }
.hint { margin-top: 12px; font-size: .85rem; color: var(--muted); }
.timeout-msg { margin-top: 12px; color: var(--bad); font-weight: 700; }

@media (min-width: 900px) {
  .item-grid.has-passage { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
  .item-grid.has-passage .passage { max-height: 68vh; position: sticky; top: 76px; margin-bottom: 0; }
}

/* Result */
.level-box { text-align: center; padding: 18px; border-radius: 12px; background: var(--navy); color: #fff; margin: 10px 0 18px; border-left: 8px solid var(--yellow); }
.level-box .lbl { font-size: .9rem; opacity: .85; }
.level-box .lvl { font-family: var(--font-display); color: var(--yellow); font-size: clamp(1.4rem, 7vw, 2.1rem); font-weight: 800; letter-spacing: .02em; }
.bands { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.bands td { padding: 10px 6px; border-bottom: 1px solid var(--line); }
.bands td:last-child { text-align: right; }
.badge { display: inline-block; white-space: nowrap; padding: 2px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.badge.good { background: #E3F4EA; color: var(--ok); }
.badge.ok { background: #FFF4DE; color: var(--warn); }
.badge.weak { background: #FDE7E5; color: var(--bad); }
.recs { padding-left: 1.2em; }
.recs li { margin-bottom: .5em; }

/* Alerts */
.alert { border-radius: 10px; padding: 12px 14px; font-size: .95rem; }
.alert-warn { background: #FFF4DE; color: #6B4600; border: 1px solid #F2D49B; }
.alert-info { background: var(--blue-soft); color: #004E82; border: 1px solid #B3D2E8; }
.alert-bad { background: #FDE7E5; color: var(--bad); border: 1px solid #F5C2BC; }
.floating { position: fixed; left: 12px; right: 12px; top: 64px; z-index: 40; max-width: 640px; margin: 0 auto; box-shadow: var(--shadow); }
.fs-prompt { margin-top: 10px; }

/* Spinner */
.spinner { width: 34px; height: 34px; border: 3px solid var(--navy-soft); border-top-color: var(--navy); border-radius: 50%; margin: 10px auto 14px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Watermark */
/* v1.5: watermark ABOVE the content (incl. the question box), pointer-events none; opacity keeps text contrast high */
.watermark { position: fixed; inset: 0; z-index: 25; pointer-events: none; opacity: .13; background-repeat: repeat; }

/* AI notice */
.ai-notice { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); font-size: 10.5px; line-height: 1.35; color: #4A5468; }
.ai-notice p { margin: 0; max-width: 1100px; margin-inline: auto; }
.ai-notice .th { color: var(--navy); font-weight: 600; margin-top: 2px; }

@media (min-width: 600px) {
  body { font-size: 18px; }
  .card { padding: 28px; }
  .btn { width: auto; min-width: 220px; }
  .parts { grid-template-columns: repeat(4, 1fr); }
}
/* print: question text hidden (anti-copy) but every anti-AI mark, the watermark and the notice still print */
@media print { .stem, .opt-text, .passage p { visibility: hidden !important; } .watermark, .live-bar, .exam-mark, .exam-statement, .ai-notice { display: block !important; visibility: visible !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* Finn CI: yellow accent stripe (as on the CI cover) and logo placement (only on white, with clear space) */
.card.accent { border-left: 6px solid var(--yellow); }
/* clear space >= half the logo height (140px wide => 82px tall => >= 41px) on white */
.logo-wrap { background: #fff; padding: 22px 41px 41px; text-align: center; }
.finn-logo { display: inline-block; width: 140px; height: auto; }
body.landing { min-height: 100vh; border-left: 10px solid var(--yellow); background: var(--navy); }
body.landing .card { border-left: 6px solid var(--yellow); }

/* Walk-in form */
.walkin h1 { font-size: 1.4rem; }
.wform { display: grid; gap: 12px; margin-top: 8px; }
.wform .row2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.wform label { display: block; font-weight: 600; color: var(--navy); font-size: .95rem; }
.wform input { display: block; width: 100%; margin-top: 4px; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 1.05rem; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.wform input:focus { border-color: var(--navy); outline: 3px solid var(--yellow-soft); }
.wform input.code { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; text-align: center; font-size: 1.25rem; }
.wform .err { color: var(--bad); font-size: .85rem; font-weight: 400; min-height: 0; }
.wform input[aria-invalid="true"] { border-color: var(--bad); }
.closed-box { background: var(--yellow-soft); border-left: 6px solid var(--yellow); border-radius: 10px; padding: 14px 16px; color: var(--navy); font-weight: 600; }
@media (max-width: 420px) { .wform .row2 { grid-template-columns: 1fr; } }
.walkin .muted.small { margin-top: 14px; }

/* §7 L5: exam top-bar logo — 48px wide (28px tall) with >= 14px clear space on the white bar */
.brand-logo { display: inline-flex; padding: 14px 14px 14px 0; flex: none; }
.brand-logo img { display: block; width: 48px; height: auto; }
.topbar-inner { padding-top: 0; padding-bottom: 0; }
.progress { color: var(--navy); }
/* §7 F3: multi-tab warning in page flow (never over the timer), closable */
.warn-slot { max-width: 760px; margin: 0 auto; padding: 0 16px; position: relative; z-index: 3; }
.tab-warn { margin-top: 12px; padding-right: 44px; position: relative; }
.warn-close { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #6B4600; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.warn-close:hover, .warn-close:focus-visible { background: rgba(0,0,0,.08); }
/* §7 L2: compact AI notice on phones; still the full EN + TH text, fully visible */
@media (max-width: 479px) {
  .ai-notice { font-size: 11px; line-height: 1.25; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
  .ai-notice .th { margin-top: 1px; }
}
.break-count { font-family: var(--font-display); font-size: 3rem; font-weight: 800; color: var(--navy); margin: 12px 0; font-variant-numeric: tabular-nums; }
.break-card { border-left: 6px solid var(--yellow); }

/* v1.5 anti-AI marks (permanent, not dismissible) */
.live-bar { background: #B42318; color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .03em;
  text-align: center; padding: 4px 10px; line-height: 1.3; }
.exam-mark { display: block; color: #B42318; font-weight: 800; font-size: 13px; letter-spacing: .06em; border: 1.5px solid #B42318; border-radius: 6px;
  padding: 2px 8px; margin: 4px 0 8px; width: fit-content; background: #fff; }
.exam-statement { font-size: 13px; line-height: 1.45; color: #3B4256; margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); }
.section-progress { font-size: .9rem; color: var(--navy); font-weight: 600; margin: -4px 0 6px; }

/* v1.5.1 reading tip on break screen */
.reading-tip{margin:16px auto;max-width:560px;padding:14px 16px;border-left:4px solid #FFC316;background:#FFF8E1;border-radius:8px;text-align:left}
.reading-tip p{margin:6px 0 0}
