@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

/* ── Tokens (all contrast ratios verified) ────────────────────────── */
:root {
  --photo-hdr:    #1e7e34;  /* white on this = 6.5:1 ✓ */
  --photo-border: #28a745;
  --photo-pale:   #edfbf0;
  --photo-text:   #145c25;  /* on white = 9.0:1 ✓ */

  --both-hdr:     #92400e;  /* white on this = 6.7:1 ✓ */
  --both-border:  #d97706;
  --both-pale:    #fffdf0;
  --both-text:    #7a3800;  /* on white = 8.9:1 ✓ */

  --resp-hdr:     #5a2d91;  /* white on this = 8.5:1 ✓ */
  --resp-border:  #7b42c8;
  --resp-pale:    #f5f0ff;
  --resp-text:    #3d1a6e;  /* on white = 12.1:1 ✓ */

  --bg:           #eef1fb;
  --surface:      #ffffff;
  --text:         #1a1a2e;  /* on bg = 14.7:1 ✓ */
  --muted:        #4a4a6a;  /* on white = 6.5:1 ✓ */
  --border-ui:    #c8d0e8;
  --focus:        #0057b8;  /* WCAG AA focus colour */
  --radius:       14px;
  --radius-sm:    9px;
  --shadow:       0 2px 10px rgba(0,0,0,0.09);
  --shadow-md:    0 6px 28px rgba(0,0,0,0.13);
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Utilities ──────────────────────────────────────────────────────── */
.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;
}
.skip-link {
  position: absolute; top: -48px; left: 8px;
  background: #000; color: #fff;
  padding: 10px 18px; border-radius: 0 0 8px 8px;
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 0.9rem;
  text-decoration: none; z-index: 1000; transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* ── Body ───────────────────────────────────────────────────────────── */
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #0c3d1c 0%, #1c0a3f 100%);
  color: #fff;
  padding: 20px 28px 18px;
  position: relative; overflow: hidden;
}
.header::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(45deg, transparent, transparent 28px,
    rgba(255,255,255,0.022) 28px, rgba(255,255,255,0.022) 56px);
}
.header-eyebrow {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 1.8px;
  text-transform: uppercase; color: rgba(255,255,255,0.7);
  margin-bottom: 6px; position: relative;
}
.header-title {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  line-height: 1.2; position: relative;
}
.header-title .vs {
  background: #fff; color: #1a1a2e;
  padding: 1px 10px; border-radius: 99px;
  font-size: 0.58em; font-family: 'Nunito', sans-serif;
  font-weight: 900; letter-spacing: 2px;
}
.header-sub {
  font-size: 0.87rem; line-height: 1.55;
  opacity: 0.82; margin-top: 8px;
  max-width: 640px; position: relative;
}
.header-sub strong { color: #9ffdb5; }

/* ── Main ───────────────────────────────────────────────────────────── */
.main { max-width: 1080px; margin: 0 auto; padding: 18px 14px 44px; }

/* ── Instructions ───────────────────────────────────────────────────── */
.instructions {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 2px solid #b8cbff;
  border-radius: var(--radius); padding: 11px 15px;
  font-size: 0.86rem; line-height: 1.6;
  color: #1c348a; /* on white = 8.9:1 ✓ */
  margin-bottom: 14px;
}
.instructions kbd {
  background: #e8edff; border: 1.5px solid #9caade;
  border-radius: 4px; padding: 0 5px;
  font-family: monospace; font-size: 0.8em; color: #1a1a2e;
}

/* ── Progress ───────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1.5px solid var(--border-ui);
  border-radius: var(--radius); padding: 10px 16px;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.progress-label {
  font-size: 0.76rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--muted); white-space: nowrap;
}
.progress-track {
  flex: 1; background: #d8ddf5; border-radius: 99px; height: 10px; overflow: hidden;
}
#progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--photo-border), var(--both-border));
  border-radius: 99px; transition: width 0.4s ease;
}
#progress-text {
  font-size: 0.82rem; font-weight: 900; color: var(--text);
  white-space: nowrap; min-width: 50px; text-align: right;
}

/* ── Results ────────────────────────────────────────────────────────── */
#results-panel[hidden] { display: none; }
#results-panel {
  margin-bottom: 16px;
}
.results-inner {
  background: var(--surface); border-radius: var(--radius);
  border-top: 5px solid var(--both-border);
  box-shadow: var(--shadow-md); padding: 22px 28px; text-align: center;
}
#score-display {
  font-family: 'Fredoka One', cursive; font-size: 3.4rem; line-height: 1;
  color: var(--photo-hdr); margin-bottom: 6px;
}
.result-msg { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.score-breakdown { font-size: 0.88rem; color: var(--muted); font-weight: 700; }

/* ── Drop zones ──────────────────────────────────────────────────────── */
.zones-section { margin-bottom: 16px; }

.zones-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* Individual zone panel */
.zone-panel {
  display: flex; flex-direction: column;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}

/* Zone colour headers */
.zone-header {
  padding: 10px 14px;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(0.82rem, 1.4vw, 1rem);
  display: flex; align-items: center; gap: 6px;
  color: #fff; letter-spacing: 0.2px;
  user-select: none;
}
.photo-header { background: var(--photo-hdr); }
.both-header  { background: var(--both-hdr); }
.resp-header  { background: var(--resp-hdr); }

/* Drop areas */
.drop-zone {
  flex: 1;
  min-height: 220px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 7px;
  position: relative;
  transition: background 0.18s, box-shadow 0.18s;
}
.photo-panel .drop-zone { background: var(--photo-pale); border: 2px dashed var(--photo-border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
.both-panel  .drop-zone { background: var(--both-pale);  border: 2px dashed var(--both-border);  border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
.resp-panel  .drop-zone { background: var(--resp-pale);  border: 2px dashed var(--resp-border);  border-top: none; border-radius: 0 0 var(--radius) var(--radius); }

/* Drag-over highlight */
.drop-zone.drag-over {
  border-style: solid; border-width: 2.5px;
}
.photo-panel .drop-zone.drag-over { background: rgba(40,167,69,0.12);  box-shadow: inset 0 0 20px rgba(40,167,69,0.15); }
.both-panel  .drop-zone.drag-over { background: rgba(217,119,6,0.12);  box-shadow: inset 0 0 20px rgba(217,119,6,0.16); }
.resp-panel  .drop-zone.drag-over { background: rgba(123,66,200,0.12); box-shadow: inset 0 0 20px rgba(123,66,200,0.15); }

/* Focus on zone (when keyboard placing) */
.drop-zone:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop-zone:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* When a card is selected, highlight zones */
body.has-selection .drop-zone {
  border-style: solid;
  cursor: pointer;
}
body.has-selection .photo-panel .drop-zone { border-color: var(--photo-hdr); background: rgba(40,167,69,0.07); }
body.has-selection .both-panel  .drop-zone { border-color: var(--both-hdr);  background: rgba(146,64,14,0.06); }
body.has-selection .resp-panel  .drop-zone { border-color: var(--resp-hdr);  background: rgba(90,45,145,0.07); }

/* Empty placeholder */
.zone-empty-hint {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
  font-size: 0.76rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; line-height: 1.7;
  opacity: 0.38; width: 90%;
}
.zone-empty-hint strong { font-size: 1.1em; }
.drop-zone.has-cards .zone-empty-hint { display: none; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  display: block; width: 100%;
  background: var(--surface);
  border: 2px solid #cdd5ee;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.83rem; font-weight: 700;
  color: var(--text); line-height: 1.38;
  text-align: left;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: element;
  box-shadow: 0 1px 5px rgba(0,0,0,0.07);
  transition: transform 0.13s ease, box-shadow 0.13s ease, border-color 0.13s ease;
  position: relative;
}
.card:hover  {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.13);
  border-color: #aab4e0;
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.4; transform: scale(0.97); cursor: grabbing; }

/* Focus ring on card */
.card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}

/* Keyboard selected */
.card.selected {
  background: #ddeeff;
  border-color: var(--focus);
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  transform: scale(1.02);
  box-shadow: 0 5px 20px rgba(0,87,184,0.22);
}
.card.selected .card-label {
  display: block;
  font-size: 0.67rem; font-weight: 900; letter-spacing: 0.5px;
  color: var(--focus); margin-bottom: 3px;
  text-transform: uppercase;
}
.card:not(.selected) .card-label { display: none; }

/* Correct / Incorrect */
.card.correct {
  background: #f0fff5; border-color: var(--photo-border);
  color: var(--photo-text); cursor: default;
}
.card.incorrect {
  background: #fff4f4; border-color: #c0392b;
  color: #7a1111; cursor: default;
}
.card .feedback-icon {
  display: inline; font-weight: 900;
  margin-left: 5px; font-size: 1em; vertical-align: middle;
}
.hint {
  display: block; font-size: 0.71rem; font-weight: 800;
  font-style: italic; color: var(--both-text); margin-top: 5px;
}

/* ── Card Bank ───────────────────────────────────────────────────────── */
.bank-wrap {
  background: var(--surface);
  border-radius: var(--radius); border: 1.5px solid var(--border-ui);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px;
}
.bank-header-bar {
  background: #e2e7f8; border-bottom: 1.5px solid var(--border-ui);
  padding: 10px 16px;
  font-size: 0.79rem; font-weight: 900; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
}
.bank-sub { font-weight: 600; text-transform: none; letter-spacing: 0; }

#card-bank {
  display: flex; flex-wrap: wrap; gap: 9px;
  padding: 13px; min-height: 60px; align-content: flex-start;
}
#card-bank .card { width: calc(33.33% - 7px); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-row { display: flex; justify-content: center; gap: 12px; margin-bottom: 20px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 28px; border: none; border-radius: 99px;
  font-family: 'Fredoka One', cursive; font-size: 1rem; letter-spacing: 0.4px;
  cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.btn-submit {
  background: linear-gradient(135deg, var(--photo-hdr), #35b053);
  color: #fff; box-shadow: 0 4px 16px rgba(30,126,52,0.3);
}
.btn-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(30,126,52,0.4); }
.btn-submit:disabled, .btn-submit[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-retry { background: linear-gradient(135deg, var(--resp-hdr), #7b42c8); color: #fff; box-shadow: 0 4px 16px rgba(90,45,145,0.3); }
.btn-retry:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(90,45,145,0.4); }
.btn-retry[hidden] { display: none; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.footer-note {
  text-align: center; font-size: 0.74rem; color: var(--muted);
  font-style: italic; font-weight: 700;
  border-top: 1.5px solid var(--border-ui); padding-top: 14px;
}

/* ── Reduced motion ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .card:hover, .card.selected, .btn:hover { transform: none !important; }
}

/* ── High-contrast mode ──────────────────────────────────────────────── */
@media (forced-colors: active) {
  .card { border: 2px solid ButtonText; }
  .card.selected { background: Highlight; color: HighlightText; border-color: Highlight; }
  .drop-zone { border: 2px solid ButtonText; }
  .zone-header { forced-color-adjust: none; }
  .btn { border: 2px solid ButtonText; forced-color-adjust: none; }
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .zones-grid { grid-template-columns: 1fr; }
  .zone-panel { border-radius: var(--radius); }
  .drop-zone { min-height: 120px; border-radius: 0 0 var(--radius) var(--radius) !important; }
  #card-bank .card { width: calc(50% - 5px); }
}
@media (max-width: 480px) {
  #card-bank .card { width: 100%; }
  .header { padding: 16px 14px; }
  .header-title { font-size: 1.25rem; }
  .instructions { font-size: 0.8rem; }
}
