/* ==========================================================================
   Apple Keynotes — Design system
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg:            #f5f5f7;
  --bg-elevated:   #ffffff;
  --bg-sunken:     #ebebef;
  --bg-hover:      #f0f0f4;
  --border:        rgba(0, 0, 0, .09);
  --border-strong: rgba(0, 0, 0, .16);

  --text:          #1d1d1f;
  --text-soft:     #55555c;
  --text-faint:    #86868b;

  --accent:        #0071e3;
  --accent-soft:   rgba(0, 113, 227, .1);

  --c-macworld:    #a25ddc;
  --c-wwdc:        #0071e3;
  --c-iphone:      #f56300;
  --c-special:     #12924a;
  --c-press:       #7d7d85;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.22), 0 6px 18px rgba(0,0,0,.12);

  --radius:    18px;
  --radius-sm: 12px;

  --rail: 92px;
  --max:  1180px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #000000;
    --bg-elevated:   #161618;
    --bg-sunken:     #0c0c0e;
    --bg-hover:      #202024;
    --border:        rgba(255, 255, 255, .1);
    --border-strong: rgba(255, 255, 255, .2);

    --text:          #f5f5f7;
    --text-soft:     #b0b0b8;
    --text-faint:    #86868b;

    --accent:        #2997ff;
    --accent-soft:   rgba(41, 151, 255, .16);

    --c-macworld:    #c07ef5;
    --c-wwdc:        #2997ff;
    --c-iphone:      #ff9f0a;
    --c-special:     #32d74b;
    --c-press:       #98989f;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 14px rgba(0,0,0,.5);
    --shadow-lg: 0 24px 70px rgba(0,0,0,.75);
  }
}

:root[data-theme="dark"] {
  --bg:            #000000;
  --bg-elevated:   #161618;
  --bg-sunken:     #0c0c0e;
  --bg-hover:      #202024;
  --border:        rgba(255, 255, 255, .1);
  --border-strong: rgba(255, 255, 255, .2);

  --text:          #f5f5f7;
  --text-soft:     #b0b0b8;
  --text-faint:    #86868b;

  --accent:        #2997ff;
  --accent-soft:   rgba(41, 151, 255, .16);

  --c-macworld:    #c07ef5;
  --c-wwdc:        #2997ff;
  --c-iphone:      #ff9f0a;
  --c-special:     #32d74b;
  --c-press:       #98989f;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* ---------- Header ------------------------------------------------------ */

.masthead {
  padding: 56px 0 28px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 320px at 12% -30%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.masthead__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.06;
  letter-spacing: -.028em;
  font-weight: 700;
}

.masthead h1 .glyph { margin-right: .3em; }

.masthead p {
  margin: 12px 0 0;
  max-width: 58ch;
  color: var(--text-soft);
  font-size: 16px;
  letter-spacing: -.01em;
}

.theme-toggle {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: grid; place-items: center;
  font-size: 17px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, background .18s;
}
.theme-toggle:hover { transform: scale(1.06); background: var(--bg-hover); }
.theme-toggle:active { transform: scale(.95); }

/* ---------- Stats ------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 12px;
  margin-top: 32px;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat__value {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat__label {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: .01em;
}

/* ---------- Controls ---------------------------------------------------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.controls__inner { padding-top: 14px; padding-bottom: 14px; }

.controls__row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.controls__row + .controls__row { margin-top: 10px; }

.search {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
}
.search svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 9px 34px 9px 34px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 14px;
  transition: border-color .16s, box-shadow .16s;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search__clear {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--border-strong);
  color: var(--bg-elevated);
  font-size: 12px;
  line-height: 1;
  display: none;
  place-items: center;
}
.search__clear.is-visible { display: grid; }

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 980px;
}
.seg button {
  padding: 6px 14px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  transition: background .16s, color .16s;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

.chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  -ms-overflow-style: none;
}
.chips--scroll::-webkit-scrollbar { height: 4px; }
.chips--scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.chip {
  --chip-color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
  transition: background .16s, color .16s, border-color .16s, transform .16s;
}
.chip:hover { background: var(--bg-hover); }
.chip:active { transform: scale(.96); }

.chip[aria-pressed="true"] {
  background: var(--chip-color);
  border-color: var(--chip-color);
  color: #fff;
}
:root[data-theme="dark"] .chip[aria-pressed="true"],
.chip[aria-pressed="true"] { color: #fff; }

.chip__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--chip-color);
  flex: none;
}
.chip[aria-pressed="true"] .chip__dot { background: rgba(255,255,255,.9); }

.chip__count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: .6;
}

.chips__label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-right: 2px;
  flex: none;
}

.reset {
  font-size: 13px;
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 980px;
  font-weight: 500;
}
.reset:hover { background: var(--accent-soft); }

.result-count {
  font-size: 13px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  white-space: nowrap;
}

/* ---------- Layout ------------------------------------------------------ */

main { padding: 36px 0 96px; min-height: 60vh; }

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-faint);
}
.empty__glyph { font-size: 42px; }
.empty h3 { margin: 14px 0 6px; color: var(--text); font-size: 19px; font-weight: 600; }
.empty p { margin: 0; font-size: 14px; }

/* ---------- Timeline ---------------------------------------------------- */

.timeline { position: relative; }

.year-block { position: relative; }

.year-head {
  position: sticky;
  top: 118px;
  z-index: 20;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0 10px;
  margin-bottom: 4px;
  background: linear-gradient(var(--bg) 68%, transparent);
}

.year-head__num {
  width: var(--rail);
  flex: none;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.year-head__meta {
  font-size: 13px;
  color: var(--text-faint);
}

.tl-item {
  position: relative;
  display: flex;
  gap: 0;
  padding-bottom: 14px;
}

.tl-item__rail {
  width: var(--rail);
  flex: none;
  position: relative;
  padding-top: 20px;
  text-align: right;
  padding-right: 22px;
}

.tl-item__date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the vertical line + node */
.tl-item__rail::before {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: -14px;
  width: 2px;
  background: var(--border);
  transform: translateX(1px);
}
.year-block:last-child .tl-item:last-child .tl-item__rail::before { bottom: 50%; }

.tl-item__rail::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 24px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--dot, var(--text-faint));
  box-shadow: 0 0 0 4px var(--bg);
  transition: transform .18s;
}
.tl-item:hover .tl-item__rail::after { transform: scale(1.35); }

.tl-item__body { flex: 1; min-width: 0; padding-left: 22px; }

/* ---------- Event card -------------------------------------------------- */

.card {
  position: relative;
  width: 100%;
  text-align: left;
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s, border-color .18s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.card:active { transform: translateY(0); }

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
}

.card__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.018em;
  line-height: 1.28;
}

.card__tagline {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-faint);
  font-style: italic;
}

.card__play {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-sunken);
  color: var(--text-soft);
  font-size: 11px;
  transition: background .18s, color .18s, transform .18s;
}
.card:hover .card__play { background: var(--accent); color: #fff; transform: scale(1.08); }
.card__play.is-missing { opacity: .35; }
.card:hover .card__play.is-missing { background: var(--bg-sunken); color: var(--text-soft); transform: none; }

.card__desc {
  margin: 9px 0 0;
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.5;
}

.card__foot {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 980px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  background: color-mix(in srgb, var(--badge-color, var(--text-faint)) 13%, transparent);
  color: var(--badge-color, var(--text-faint));
  border: 1px solid color-mix(in srgb, var(--badge-color, var(--text-faint)) 26%, transparent);
  white-space: nowrap;
}

.tag {
  padding: 3px 9px;
  border-radius: 980px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-sunken);
  color: var(--text-soft);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.card mark, .modal mark {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ---------- Grid view --------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(305px, 1fr));
  gap: 16px;
}

.grid .card { height: 100%; display: flex; flex-direction: column; }
.grid .card__desc { flex: 1; }

.grid__year {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 20px;
  padding-bottom: 4px;
}
.grid__year:first-child { margin-top: 0; }
.grid__year b {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.grid__year span { font-size: 13px; color: var(--text-faint); }

.grid .card__date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  display: block;
}

/* ---------- Modal ------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: min(880px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  animation: pop .24s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.98) }
  to   { opacity: 1; transform: none }
}

.modal__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 22px 22px 0 0;
  overflow: hidden;
}
.modal__media iframe { width: 100%; height: 100%; border: 0; display: block; }

.modal__novideo {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  color: #d0d0d6;
  background: linear-gradient(150deg, #1c1c1f, #08080a);
}
.modal__novideo .g { font-size: 34px; }
.modal__novideo p { margin: 0; font-size: 14px; max-width: 40ch; }

.modal__close {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 2;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  display: grid; place-items: center;
  font-size: 15px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background .16s, transform .16s;
}
.modal__close:hover { background: rgba(0,0,0,.8); transform: scale(1.08); }

.modal__body { padding: 24px 28px 28px; }

.modal__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.modal__date { font-size: 13px; color: var(--text-faint); font-weight: 500; }

.modal h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 29px);
  letter-spacing: -.026em;
  line-height: 1.12;
  font-weight: 700;
}
.modal__tagline {
  margin: 6px 0 0;
  color: var(--text-faint);
  font-size: 15px;
  font-style: italic;
}
.modal__desc {
  margin: 16px 0 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-soft);
}

.modal__section { margin-top: 22px; }
.modal__section h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
  font-weight: 650;
}

.announce {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 7px;
}
.announce li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14.5px;
  color: var(--text);
  padding: 9px 12px;
  background: var(--bg-sunken);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.announce li::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  transform: translateY(-2px);
}

.modal__links {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.linkbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  transition: background .16s, transform .16s;
}
.linkbtn:hover { background: var(--bg-hover); }
.linkbtn:active { transform: scale(.97); }
.linkbtn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.linkbtn--primary:hover { filter: brightness(1.08); background: var(--accent); }

.modal__nav {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.navbtn {
  font-size: 13.5px;
  color: var(--text-soft);
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 46%;
  text-align: left;
  transition: background .16s, color .16s;
}
.navbtn:hover:not(:disabled) { background: var(--bg-sunken); color: var(--text); }
.navbtn:disabled { opacity: .3; cursor: default; }
.navbtn span { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 1px; }
.navbtn--next { text-align: right; }
.navbtn strong { font-weight: 550; }

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

.foot {
  border-top: 1px solid var(--border);
  padding: 26px 0 40px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.foot p { margin: 0 0 6px; }
.foot a { color: var(--text-soft); }

.card__mobile-date { display: none; }

/* ---------- Responsive -------------------------------------------------- */

@media (max-width: 760px) {
  :root { --rail: 0px; }
  .wrap { padding: 0 16px; }
  .masthead { padding: 34px 0 22px; }

  .year-head { top: 150px; }
  .year-head__num { width: auto; font-size: 25px; }

  .tl-item { padding-bottom: 12px; }
  .tl-item__rail { display: none; }
  .tl-item__body { padding-left: 0; }

  .tl-item .card__mobile-date {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
  }

  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { max-height: 94vh; border-radius: 20px 20px 0 0; }
  .modal__media { border-radius: 20px 20px 0 0; }
  .modal__body { padding: 20px 18px 32px; }
  .result-count { margin-left: 0; }
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
