/* style.css: Toyota MR2 Guide. Mobile first (412px), then larger screens. */

:root {
  --accent: #e53935;
  --ink: #141414;
  --ink-soft: #4a4a4a;
  --paper: #f7f5f0;
  --paper-2: #efece4;
  --line: #dcd8cd;
  --ok: #2e7d32;
  --ok-bg: #e6f4e7;
  --bad: #b71c1c;
  --bad-bg: #fdecec;
  --radius: 16px;
  --radius-sm: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  font-weight: 800;
}

p {
  margin: 0 0 1em;
  color: var(--ink-soft);
}

ul {
  margin: 0;
  padding-left: 1.2em;
}

li {
  margin: 0 0 0.5em;
  color: var(--ink-soft);
}

button {
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Hero ---------- */

#hero {
  position: relative;
  padding: 0 0 20px;
  background: var(--ink);
  overflow: hidden;
}

#hero-img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  opacity: 0.9;
}

#hero h1 {
  margin: 0;
  padding: 18px 20px 4px;
  color: #fff;
  font-size: 2.2rem;
  font-weight: 900;
}

#hero p,
#hero .intro {
  margin: 0;
  padding: 0 20px;
  color: #d9d6cf;
  font-size: 1rem;
}

#hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--accent);
}

/* ---------- Generation tabs (sticky) ---------- */

#tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: rgba(247, 245, 240, 0.94);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

#tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.tab:hover {
  border-color: var(--ink);
}

.tab:active {
  transform: scale(0.97);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(229, 57, 53, 0.28);
}

.tab[data-gen="aw11"]::after {
  content: " \2605";
  color: inherit;
}

.tab.active[data-gen="aw11"]::after {
  color: #fff;
}

/* ---------- Panel ---------- */

#panel {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 18px 8px;
}

#gen-photo {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 0 18px;
  background: var(--paper-2);
}

#gen-title {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 0.3em;
}

#gen-story {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin-bottom: 1.4em;
}

#panel h3 {
  font-size: 1.15rem;
  margin: 1.6em 0 0.6em;
  padding-top: 0.2em;
  position: relative;
  padding-left: 14px;
}

#panel h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.3em;
  bottom: 0.3em;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}

#gen-specs {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  font-size: 0.95rem;
}

#gen-specs caption {
  text-align: left;
  padding: 0 0 8px;
  font-weight: 700;
  color: var(--ink);
}

#gen-specs th,
#gen-specs td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

#gen-specs tr:last-child th,
#gen-specs tr:last-child td {
  border-bottom: 0;
}

#gen-specs th {
  width: 40%;
  color: var(--ink);
  font-weight: 700;
  background: var(--paper-2);
}

#gen-specs td {
  color: var(--ink-soft);
}

#gen-specs tbody tr:nth-child(even) td,
#gen-specs tbody tr:nth-child(even) th {
  background-color: #fafaf7;
}

#gen-why li,
#gen-mods li {
  position: relative;
  padding: 10px 14px 10px 36px;
  margin: 0 0 8px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

#gen-why,
#gen-mods {
  padding: 0;
  margin: 0 0 8px;
}

#gen-why li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 17px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

#gen-mods li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 17px;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--ink);
}

/* Second image in SW20 panel (dashboard shot) */
#gen-photo-2,
#panel img.gen-extra {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 16px 0 0;
  background: var(--paper-2);
}

/* Fade-in on panel change */
.fade-in {
  animation: fadeIn 0.45s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Quiz ---------- */

#quiz {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 18px 8px;
}

#quiz h2 {
  font-size: 1.6rem;
  font-weight: 900;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(20, 20, 20, 0.05);
}

#q-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 16px;
  line-height: 1.35;
}

#q-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  line-height: 1.3;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.option:hover:not(:disabled) {
  border-color: var(--ink);
  background: #fff;
}

.option:active:not(:disabled) {
  transform: scale(0.985);
}

.option:disabled {
  cursor: default;
}

.option.correct {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

.option.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

#q-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 6px 16px rgba(229, 57, 53, 0.25);
  transition: transform 0.15s ease, opacity 0.2s ease, background 0.2s ease;
}

#q-next:hover:not(:disabled) {
  background: #cc2f2c;
}

#q-next:active:not(:disabled) {
  transform: scale(0.97);
}

#q-next:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: not-allowed;
}

#q-score {
  margin: 14px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  min-height: 1.6em;
}

#q-score.final {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
}

/* ---------- Share ---------- */

#share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  margin: 28px 18px 8px;
  padding: 12px 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  font-size: 1rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

#share:hover {
  background: var(--ink);
  color: #fff;
}

#share:active {
  transform: scale(0.97);
}

/* Share sits at the bottom, centered on the page */
body > #share,
#share:last-of-type {
  display: flex;
  width: calc(100% - 36px);
  max-width: 300px;
  margin: 28px auto 40px;
}

/* ---------- Footer / misc ---------- */

footer {
  padding: 16px 18px 32px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.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;
}

/* ---------- Larger screens ---------- */

@media (min-width: 600px) {
  #hero {
    padding-bottom: 28px;
  }

  #hero-img {
    height: 340px;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  #hero h1 {
    font-size: 3.2rem;
    padding: 28px 28px 6px;
  }

  #hero p,
  #hero .intro {
    padding: 0 28px;
    font-size: 1.15rem;
    max-width: 640px;
  }

  #tabs {
    justify-content: center;
    padding: 12px 20px;
  }

  #panel {
    padding: 36px 28px 12px;
  }

  #gen-photo {
    aspect-ratio: 16 / 9;
    border-radius: 20px;
  }

  #gen-title {
    font-size: 2.6rem;
  }

  #gen-story {
    font-size: 1.15rem;
  }

  #gen-why,
  #gen-mods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  #gen-why li,
  #gen-mods li {
    margin: 0;
  }

  #quiz {
    padding: 36px 28px 12px;
  }

  #q-options {
    grid-template-columns: 1fr 1fr;
  }

  .card {
    padding: 28px;
  }

  #q-text {
    font-size: 1.4rem;
  }
}

@media (min-width: 1000px) {
  #hero-img {
    height: 420px;
  }

  #hero h1 {
    font-size: 4rem;
  }

  #panel,
  #quiz {
    max-width: 960px;
  }
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Top bar (site head) ---------- */

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand .dot {
  color: var(--accent);
}

.skip {
  position: absolute;
  left: 12px;
  top: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
  z-index: 30;
}

.skip:focus {
  transform: none;
}

/* ---------- Tabs: horizontal scroll with fade edge ---------- */

#tabs {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  scroll-snap-type: x proximity;
}

#tabs .tab {
  scroll-snap-align: start;
}

@media (min-width: 600px) {
  #tabs {
    -webkit-mask-image: none;
            mask-image: none;
  }
}

/* ---------- Share button (lives in the hero) ---------- */

#hero .share-btn,
#hero #share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  margin: 16px 20px 0;
  padding: 12px 22px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

#hero .share-btn:hover,
#hero #share:hover {
  background: #fff;
  color: var(--ink);
}

#hero .share-btn:active,
#hero #share:active {
  transform: scale(0.97);
}

@media (min-width: 600px) {
  #hero .share-btn,
  #hero #share {
    margin: 20px 28px 0;
  }
}
