/*v.01.4*/

:root {
  --bg:#0f1115;
  --panel:#181b22;
  --muted:#8b93a7;
  --text:#e7ecf3;
  --accent:#5dd4ff;
  --accent-2:#7effa1;
  --danger:#ff5d73;
  --correct:#1db954;
  --wrong:#e63946;
  --btn:#222631;
  --outline:2px solid rgba(93,212,255,.5);
  --radius:14px;
  --shadow:0 10px 30px rgba(0,0,0,.35);
}

/* --- Body: allow scrolling instead of full flex centering --- */
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(93,212,255,.15), transparent),
              radial-gradient(800px 400px at -10% 110%, rgba(126,255,161,.12), transparent),
              var(--bg);
  color: var(--text);
  line-height: 1.4;

  /* ✅ allow page scroll if content is tall */
  display: block;
  overflow-y: auto;
}

.wrap {
  max-width: 1100px;
  margin: 40px auto;   /* center horizontally only */
  padding: 0 20px;
  transform: scale(1.0); /* remove forced scaling so layout is predictable */
}
.head {
  display: flex;
  margin-bottom: 10px;
  flex-direction: column;
  gap: 10px;
}
.title { font-weight:800; font-size: clamp(20px, 3.6vw, 36px); letter-spacing:.4px; }
.subtitle { color:var(--muted); font-size:clamp(12px,1.6vw,14px); }

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.controls-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel {
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
  border:1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hud {
  display:grid; grid-template-columns:1fr auto; gap:10px; align-items:center;
  padding:12px 14px; border-bottom:1px solid rgba(255,255,255,.06);
}
.badge {
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:999px;
  background:rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.08);
  color:var(--muted); font-weight:600;
}
.score{color:var(--accent-2)}
.best{color:var(--accent)}

button, .btn {
  background:var(--btn);
  border:1px solid rgba(255,255,255,.08);
  color:var(--text);
  padding:12px 14px; border-radius:10px;
  cursor:pointer; font-weight:700;
  transition:.2s transform ease, .2s background ease, .2s border-color ease, .2s filter ease;
}
button:hover{filter:brightness(1.12)}
button:active{transform:translateY(1px) scale(.998)}
button:focus-visible{outline:var(--outline);outline-offset:2px}
.ghost{background:transparent}
.primary{background:linear-gradient(180deg, #2e87ff, #2166ff); border-color:rgba(255,255,255,.15)}
.danger{background:linear-gradient(180deg, #ff6b6b, #ef476f)}

.grid{display:grid;gap:14px;padding:16px;}

.panel {
  display: grid;
  grid-template-areas:
    "hud"
    "topbar"
    "game";   /* default desktop order */
}

.hud      { grid-area: hud; }
.topbar   { grid-area: topbar; }
.game-layout { grid-area: game; }

.question {
  padding:20px 0; border-bottom:1px dashed rgba(255,255,255,.07);
  font-size: clamp(16px,2.6vw,22px); font-weight:700;
}
.choices {
  display:grid;
  grid-template-columns: 1fr 1fr;  /* 2 by 2 grid */
  gap:20px;
  padding: 0;
}
.choice {
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.03);
  border-radius:12px; padding:12px 14px;
  display:flex; align-items:center; gap:12px;
  text-align:left; width:100%;
}
.choice[aria-disabled="true"]{opacity:.55; pointer-events:none}
.choice .letter {
  width:32px;height:32px;display:grid;place-items:center;
  border-radius:8px;background:rgba(255,255,255,.06);color:var(--muted);
  font-weight:800; flex-shrink:0;
}
.choice.correct{border-color:rgba(46,255,164,.5); background:rgba(46,255,164,.08)}
.choice.correct .letter{background:rgba(46,255,164,.18); color:#8dffcc}
.choice.wrong{border-color:rgba(255,107,107,.5); background:rgba(255,107,107,.08)}
.choice.wrong .letter{background:rgba(255,107,107,.18); color:#ffb3bd}

.choice:hover {
  border-color: var(--accent);      /* light blue highlight */
  background: rgba(93,212,255,0.08); /* subtle glow */
  filter: brightness(1.1);
}

.feedback {
  padding: 20px 0; border-top:1px solid rgba(255,255,255,.06);
  display:none;
}
.feedback.show{display:block}
.answer-card {
  display:grid;
  grid-template-columns: 180px 1fr; /* bigger portrait */
  gap:20px;
  align-items:center;
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  padding:18px;
}

.answer-card{
  display:block;                    /* no image column anymore */
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  padding:18px;
}
.answer-card h3{ margin:0 0 8px 0; font-size:22px; }
.answer-card p{ margin:4px 0; color:var(--muted); font-size:16px; }
p#answerMeta { font-weight: bold;}
p#answerFact { font-style: italic;}
#answerBio {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  line-height: 1.5;
}

.toolbar {
  display:flex; gap:10px; justify-content:flex-end; padding:12px 16px;
  border-top:1px solid rgba(255,255,255,.06);
}
.progress {
  height:8px; width:100%; background:rgba(255,255,255,.08);
  border-radius:999px; overflow:hidden;
}
.progress > span {
  display:block; height:100%; width:0%;
  background:linear-gradient(90deg, var(--accent), var(--accent-2));
  transition:width .3s ease;
}

.topbar {
  display:grid; grid-template-columns: 1fr 180px; gap:14px; align-items:center;
  padding: 10px 14px;
}
/* ——— Two-column game area (left: question+choices, right: image) ——— */
.game-layout {
  display: grid;
  grid-template-columns: 3fr 1fr;   /* left wider, right narrower */
  gap: 20px;
  align-items: stretch;
  padding: 16px;
}

/* Left column: let questions flow normally */
.left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: flex-start;
}

/* Right column: image aligned to the bottom */
.right {
  display: flex;
  justify-content: center;   /* center horizontally */
  align-items: flex-start;     /* stick to bottom of the column */
}

/* Image styling */
.right img {
  width: 100%;                   /* shrink size */
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: #151821;
  box-shadow: var(--shadow);

  /* ✅ safety net: never exceed 80% of viewport height */
  max-height: 80vh;
}

/* Stack columns on small screens */
@media (max-width: 820px){
  .game-layout {
    grid-template-columns: 1fr;
  }
  .left  { order: 2; }  /* questions go second */
  .right { order: 1; }  /* image goes first */
  .choices { grid-template-columns: 1fr; }
  .panel {
    grid-template-areas:
      "hud"
      "game"
      "topbar";  /* 👈 mobile order: topbar after game */
  }
  .choices {
    gap: 10px;
  }
  .right img {
    width: 50%;
  }
}

.footer-note { color:var(--muted); font-size:14px; font-weight: 500; text-align:center; margin-top:20px }

@media (max-width:680px){
  .answer-card{grid-template-columns:1fr}
  .hud{grid-template-columns:1fr 1fr; gap:8px}
  .topbar{grid-template-columns:1fr auto}
}

/* ——— Poster Splash / Lightbox ——— */
.modal {
  position: fixed; inset: 0;
  display: none;
  z-index: 9999;
}
.modal.show { display: block; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(2px);
  border-radius: 12px;
}
.modal__dialog {
  position: relative;
  background: #181b22;     /* keep modal background */
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;         /* not too wide */
  max-height: 90vh;        /* not too tall */
  overflow: auto;          /* scroll if content overflows */
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

.modal__img {
  max-width: 100%;
  max-height: 70vh;        /* leave space for the button */
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 20px;     /* space for the button */
}
.modal__caption {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  display: none;
}
.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.modal__close:hover {
  background: rgba(255,255,255,0.2);
}
#startQuiz {
  margin-top: 8px;
  padding: 10px 16px;
  font-size: 16px;
}
/* Start Quiz button in poster modal */
.start-btn {
  margin-top: auto;
  font-size: 18px;
  padding: 12px 24px;
  border-radius: 10px;
  background: linear-gradient(180deg, #2e87ff, #2166ff);
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  transition: transform 0.15s ease, filter 0.2s ease;
}
.start-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}
.start-btn:active {
  transform: translateY(0);
}


/* ===== History Page (gallery) ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* wider cards */
  gap: 24px;  /* a bit more breathing room */
  width: 100%;
}

.card{
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
  padding:12px;
  text-align:left;
  box-shadow: var(--shadow);
}
.card h3{ margin:8px 0; font-size:18px; }
.card p{ margin:4px 0; }
.card .muted{ color: var(--muted); margin: 10px 0; }

.card img{
  width:100%;
  aspect-ratio: 1 / 1;
  object-fit:cover;
  border-radius:8px;
  margin-bottom:8px;
  background:#151821;
  border:1px solid rgba(255,255,255,.06);
}

.card .bio {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  line-height: 1.5;
}



/* === Timeline Page === */
:root {
  --card-width: 160px;
  --card-padding: 12px;
}

.timeline-container {
  position: relative;
  width: 100%;
  height: 80vh;
  display: flex;
  align-items: center;         /* center vertically */
  justify-content: flex-start; /* left aligned, scrollable */
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-line {
  position: absolute;
  height: 4px;
  background: rgba(255,255,255,0.4);
  width: 100%;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* --- Ticks --- */
.tick {
  position: absolute;
  top: -10px;
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.5);
}
.tick-label {
  position: absolute;
  top: 20px;
  font-size: 12px;
  color: var(--muted);
  transform: translateX(-50%);
}
/* --- Timeline Items --- */
.timeline-item {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: center;
  z-index: 1;
  transition: z-index 0s;
}
.timeline-item:hover,
.timeline-item.expanded {
  z-index: 10;   /* bring to front */
}

/* Alternate positioning */
.timeline-item.up {
  transform: translateY(-100%); /* above line */
  justify-content: flex-end;
}
.timeline-item.down {
  transform: translateY(0%);    /* below line */
  justify-content: flex-start;
}

/* --- Connector + Dot --- */
.timeline-item .connector {
  width: 2px;
  background: var(--accent);
  height: 40px;
  position: relative;
  z-index: 1;
  left: calc((var(--card-width) + (var(--card-padding) * 2)) / 2);
}
.timeline-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
/* Dot placement depending on up/down */
.timeline-item.up .dot {
  bottom: -5px;    /* sits at bottom of connector near timeline */
}
.timeline-item.down .dot {
  top: -5px; /* sits at top of connector near timeline */
}
/* Order control (so connector + card flip correctly) */
.timeline-item.up .connector {
  order: 2; /* connector after card (below it) */
}
.timeline-item.up .card {
  order: 1;
}
.timeline-item.down .connector {
  order: 1; /* connector before card (above it) */
}
.timeline-item.down .card {
  order: 2;
}

/* --- Card --- */
.timeline-item .card {
  display: grid;
  grid-template-columns: 160px; /* only portrait by default */
  width: var(--card-width);
  padding: var(--card-padding);
  height: 300px;                /* 🔹 fixed height */
  background: rgba(24, 27, 34, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: width 0.3s ease;
  z-index: 2;
}

.timeline-item .main {
  width: 160px;
}
.timeline-item .main img {
  width: 100%;
  border-radius: 6px;
  aspect-ratio: 3/4;
  object-fit: cover;
}
.timeline-item h3 {
  font-size: 14px;
  margin: 4px 0;
}
.timeline-item p {
  font-size: 12px;
  margin: 2px 0;
  color: var(--muted);
}

/* --- Extra info --- */
.timeline-item .extra {
  display: none;
  font-size: 12px;
  text-align: left;
  color: var(--muted);
  padding: 6px;
  overflow-y: auto;
}

/* --- Expanded state --- */
.timeline-item.expanded .card {
  grid-template-columns: 160px 1fr; /* portrait + info */
  width: 360px;                     /* expand sideways */
  background: rgba(24, 27, 34, 0.85);
  border: 1px solid var(--accent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  gap: 12px;
}
.timeline-item.expanded .extra {
  display: block;
}
.timeline-item.expanded .card h3,
.timeline-item.expanded .card p {
  color: var(--text); /* full contrast */
}




/* helpers for mobile math */
:root{
  --card-total: calc(var(--card-width) + var(--card-padding) * 2);
}

/* ===== Vertical timeline (mobile) ===== */
@media (max-width: 768px){
  .timeline-container{
    height: auto;
    padding: 40px 0;
    align-items: stretch;
  }

  /* spine becomes vertical */
  .timeline-line{
    width: 4px !important;
    height: 100% !important;
    left: 50% !important;
    top: 0 !important;
    transform: translateX(-50%) !important;
  }

  /* items use absolute top (year), alternate left/right of spine */
  #timeline{
    position: static;
    min-height: auto;
  }

  .timeline-item{
    position: absolute;
    transform: none !important;
    display: flex;
    align-items: flex-start;
    margin: 0;
  }

  /* left side (was “up”) */
  .timeline-item.up{
    left: calc(50% - var(--card-total) - -14px); /* 24px gutter from spine */
    flex-direction: row-reverse;
    text-align: right;
  }
  /* right side (was “down”) */
  .timeline-item.down{
    left: calc(50% + 0px);
    flex-direction: row;
    text-align: left;
  }

  /* connector is horizontal on mobile */
  .timeline-item .connector{
    width: 24px;
    height: 2px;
    left: 0;            /* ignore desktop centering */
    margin: 0;
    top: 100px;
    background: var(--accent);
  }

  /* dot sits at the spine edge */
  .timeline-item .dot{
    position: absolute;
    width: 10px; 
    height: 10px; 
    border-radius: 50%;
    background: var(--accent);
    top: 1px!important;
    left: 19px;
    transform: translateY(-50%);
  }
  .timeline-item.up .dot{ right: -5px; }   /* touches spine */
  .timeline-item.down .dot{ left: -5px; }  /* touches spine */

  /* cards a bit smaller; expand vertically */
  .timeline-item .card{
    transition: none !important;
    width: 120px;
    height: auto;
    grid-template-columns: 1fr;
  }
  .timeline-item .main{ width: 100%; }
  .timeline-item .main img{ aspect-ratio: 3/4; }

  
  .timeline-item.expanded .card {
    display: block;
    width: 120px;        /* smaller, vertical stack */
    height: auto;
  }
  .timeline-item.expanded .extra {
    display: block;
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
  }

  /* ticks/labels turn vertical too (optional: slimmer labels) */
  .tick{
    left: 50% !important;
    transform: translateX(-50%);
    width: 4px; height: 1px;  /* tiny notch on the spine */
    top: auto;
  }
  .tick-label{
    transform: none !important;
    left: 50% !important;
    margin-left: 0 !important;
    translate: -50% 0;
    top: 0;  /* JS will set per-year positions */
    font-size: 11px;
    opacity: .75;
  }
  .timeline-item.up .connector {
    order: 1;
  }
  .timeline-item.up .card {
    order: 2;
  }
  /* Rotate tick labels in vertical mode */
  .tick-label {
    transform: rotate(-90deg) !important;
    transform-origin: left center; /* adjust anchor point */
    left: -20px;                   /* nudge away from the line */
    font-size: 11px;               /* smaller if needed */
    white-space: nowrap;           /* prevent wrapping */
  }
  .head {
    margin-top: 40px;
  }
  .wrap {
    margin: 0 auto;
  }
}

