@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@500;600;700&family=Nunito:wght@700;800;900&display=swap");

:root { color-scheme: light; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

#stars, #map, #sky-decor { position: fixed; inset: 0; width: 100%; height: 100%; }
#stars { z-index: 0; }
#map { z-index: 1; background: transparent; }
#map { transition: filter .35s ease; }
#map canvas { cursor: grab; }
#map canvas:active { cursor: grabbing; }
#sky-decor { z-index: 2; overflow: hidden; pointer-events: none; transition: opacity .7s ease; }
body.map-close #sky-decor { opacity: 0; }

.cloud {
  position: absolute;
  width: 120px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 221, 187, .22);
  filter: blur(.2px);
  animation: cloud-drift 26s linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.cloud::before { width: 52px; height: 52px; left: 22px; bottom: 4px; }
.cloud::after { width: 68px; height: 68px; right: 14px; bottom: 0; }
.cloud-one { top: 18%; left: -140px; transform: scale(.65); }
.cloud-two { top: 66%; left: -180px; transform: scale(1.1); animation-delay: -10s; }
.cloud-three { top: 38%; left: -140px; transform: scale(.42); animation-delay: -19s; }
@keyframes cloud-drift { to { left: calc(100% + 180px); } }

#brand {
  position: fixed;
  z-index: 5;
  top: 28px;
  left: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  filter: drop-shadow(0 2px 12px rgba(55, 33, 39, .18));
  transition: color .3s ease;
}
body:not(.ready) #brand, body:not(.ready) #hud { opacity: 0; transform: translateY(-8px); }
body.ready #brand { animation: chrome-in .65s cubic-bezier(.2,.8,.2,1) both; }
body.ready #hud { animation: hud-in .65s .15s cubic-bezier(.2,.8,.2,1) both; }
@keyframes chrome-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes hud-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.brand-orbit {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 3px solid currentColor;
  border-radius: 50%;
  transform: rotate(-12deg);
  box-shadow: inset 0 0 0 7px rgba(247, 184, 75, .28);
}
.brand-orbit::after {
  content: "";
  position: absolute;
  width: 58px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
}
.brand-orbit span { color: #f7b84b; transform: rotate(12deg); }
#brand h1 {
  margin: 0;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: clamp(25px, 3vw, 39px);
  line-height: .92;
  letter-spacing: -.045em;
  font-weight: 900;
}
#brand p { margin: 5px 0 0 2px; font-size: 11px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; opacity: .72; }
body.map-close #brand { color: var(--street-ink); }

#hud, #home-button {
  position: fixed;
  z-index: 5;
  border: 1px solid rgba(255, 248, 232, .3);
  color: var(--ink);
  background: rgba(93, 72, 91, .54);
  box-shadow: 0 8px 25px rgba(40, 26, 42, .16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#hud {
  left: 50%;
  bottom: 25px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
}
.hud-icon { color: #f7b84b; animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: rotate(20deg) scale(1.25); } }

#home-button {
  right: 26px;
  top: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 16px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity .25s, transform .25s, background .25s;
}
#home-button span:first-child { transform: rotate(-45deg); font-size: 17px; }
body.map-close #home-button {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  color: var(--street-ink);
  background: rgba(255, 247, 226, .88);
  border-color: rgba(104, 76, 61, .18);
}
#home-button:hover { transform: translateY(-2px) rotate(-1deg); }
body.map-close #hud { color: var(--street-ink); background: rgba(255, 247, 226, .86); border-color: rgba(104, 76, 61, .18); }

/* --- Find your school ------------------------------------------------------
 *
 * The globe browses; this finds. It sits on dark space at planet zoom and on
 * pastel land up close, so it carries its own solid ground rather than
 * borrowing whatever is behind it. */

#search {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: 26px;
  width: min(390px, calc(100vw - 320px));
  transform: translateX(-50%);
  transition: opacity .3s;
}
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  color: var(--panel-ink-dim);
  font-size: 17px;
  transform: translateY(-50%);
  pointer-events: none;
}
#search-input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--panel-ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(38, 24, 46, .22);
  outline: none;
  transition: box-shadow .2s, border-color .2s;
}
#search-input::placeholder { color: var(--panel-ink-dim); font-weight: 600; }
#search-input:focus { border-color: rgba(238, 99, 63, .5); box-shadow: 0 12px 30px rgba(38, 24, 46, .28); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

#search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 52px;
  max-height: min(52vh, 380px);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(38, 24, 46, .26);
}
#search-results[hidden] { display: none; }
.search-result {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--panel-ink);
  cursor: pointer;
}
.search-result.is-highlighted { background: var(--accent-soft); }
.search-result-name { font-size: 14px; font-weight: 700; }
.search-result-meta { color: var(--panel-ink-dim); font-size: 11px; font-weight: 600; }

body.feed-open #search { opacity: 0; pointer-events: none; }

@media (max-width: 900px) {
  #search { top: 78px; width: min(420px, calc(100vw - 34px)); }
}

/* --- Category filter -------------------------------------------------------
 *
 * On the globe, not inside a school: "which schools have dorm videos" is a
 * question a student asks, and a filter that matches few schools is
 * informative where an empty tab would just look broken. */

#filters {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: 74px;
  display: flex;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 0 4px;
  overflow-x: auto;
  transform: translateX(-50%);
  scrollbar-width: none;
  transition: opacity .3s;
}
#filters::-webkit-scrollbar { display: none; }
.filter-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 8px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--panel-ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(38, 24, 46, .18);
  transition: transform .16s, background .16s, color .16s;
}
.filter-chip:hover { transform: translateY(-1px); }
.filter-chip.is-active { background: var(--accent); color: #fff8e8; border-color: transparent; }
.filter-count {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--panel-ink-dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.filter-chip.is-active .filter-count { background: rgba(255, 248, 232, .26); color: #fff8e8; }

body.feed-open #filters { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  #filters { bottom: 66px; justify-content: flex-start; }
  .filter-chip { padding: 7px 12px; font-size: 11px; }
}

/* --- The feed --------------------------------------------------------------
 *
 * Full screen, one video per page, paged vertically. The stage letterboxes:
 * 38% of the videos are 16:9 and cropping them to a phone frame would cut the
 * subject out, so the picture is fitted whole and the surround is dark. */

#feed {
  position: fixed;
  inset: 0;
  z-index: 12;
  overflow: hidden;
  overflow: clip;
  overscroll-behavior: none;
  background: #16121f;
  color: #fff8e8;
}
#feed[hidden] { display: none; }
body.feed-open #brand,
body.feed-open #hud,
body.feed-open #home-button,
body.feed-open #sky-decor { opacity: 0; pointer-events: none; }

.feed-track {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  touch-action: none;
  transform: translate3d(0, calc(var(--position, 0) * -100% + var(--drag, 0px)), 0);
}
.feed-track.is-animating { transition: transform .34s cubic-bezier(.2, .82, .2, 1); }
.feed-track.is-dragging { cursor: grabbing; }

.feed-slide {
  flex: 0 0 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  padding: 84px 20px 20px;
}

.feed-stage { display: grid; place-items: center; min-height: 0; container-type: size; }

/* Letterboxing, done exactly: the largest box of the embed's own ratio that
 * fits the stage. `aspect-ratio` with max-width/max-height is not equivalent —
 * it lets one axis clamp without the other following, which squashed portrait
 * players into a landscape box. */
.player {
  position: relative;
  width: min(100cqw, calc(100cqh * var(--aspect, 1.7778)));
  height: min(100cqh, calc(100cqw / var(--aspect, 1.7778)));
  overflow: hidden;
  border-radius: 18px;
  background: #000;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* The tap-to-play surface stops short of the platform's own control strip so
 * the timeline, mute and fullscreen buttons stay reachable. */
.player-gesture-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 58px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.player[data-playback="idle"] .player-gesture-layer::after {
  content: "▶";
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  padding-left: 5px;
  border: 3px solid rgba(255, 248, 232, .9);
  border-radius: 50% 47% 52% 45%;
  background: rgba(31, 20, 34, .48);
  color: #fff8e8;
  font-size: 24px;
  transform: translate(-50%, -50%);
  transition: transform .2s;
}
.player-gesture-layer:hover::after { transform: translate(-50%, -50%) scale(1.06); }

.poster { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; padding: 0; border: 0; color: #fff8e8; background: linear-gradient(145deg, #6c4a63, #a9675d); cursor: pointer; }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.play-glyph { z-index: 1; display: grid; place-items: center; width: 61px; height: 61px; border: 3px solid rgba(255, 255, 255, .88); border-radius: 50% 47% 52% 45%; background: rgba(31, 20, 34, .55); font-size: 23px; }
.poster-hint { position: absolute; z-index: 1; left: 16px; bottom: 13px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }

.feed-meta { display: grid; gap: 8px; padding: 14px 4px 0; max-width: 760px; width: 100%; margin: 0 auto; }
.feed-chip-row { display: flex; gap: 8px; }
.feed-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(247, 184, 75, .2);
  color: #f7cf8b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.feed-title { margin: 0; font: 700 clamp(15px, 1.5vw, 19px)/1.35 "DM Sans", sans-serif; }
.feed-credits { display: flex; align-items: center; gap: 14px; font-size: 12px; }
.feed-creator { color: #ffd38b; font-weight: 700; text-decoration: none; }
.feed-creator:hover { text-decoration: underline; }
.feed-source { margin-left: auto; color: rgba(255, 248, 232, .62); font-weight: 700; text-decoration: none; }
.feed-source:hover { color: #fff8e8; }

.feed-header {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(18px + env(safe-area-inset-top, 0px))
           calc(20px + env(safe-area-inset-right, 0px)) 34px
           calc(20px + env(safe-area-inset-left, 0px));
  pointer-events: none;
  background: linear-gradient(rgba(12, 9, 17, .82), rgba(12, 9, 17, 0));
}
.feed-header > * { pointer-events: auto; }
.feed-identity { min-width: 0; }
.feed-school { margin: 0; font: 800 clamp(19px, 2vw, 25px)/1.1 "Nunito", sans-serif; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-place { margin: 3px 0 0; color: rgba(255, 248, 232, .62); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.feed-count { margin-left: auto; font-size: 12px; font-weight: 700; color: rgba(255, 248, 232, .72); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-close {
  flex: none;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 248, 232, .22);
  border-radius: 50%;
  background: rgba(24, 18, 30, .6);
  color: #fff8e8;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: transform .18s, background .18s;
}
.feed-close:hover { transform: scale(1.06); background: rgba(46, 34, 56, .8); }

/* One segment per video on this campus — familiar from stories, and it says
 * how much of this school is left without a navigation structure. */
.feed-progress {
  position: absolute;
  z-index: 3;
  left: calc(20px + env(safe-area-inset-left, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  top: calc(8px + env(safe-area-inset-top, 0px));
  display: flex;
  gap: 4px;
}
.feed-progress-segment { flex: 1; height: 3px; border-radius: 999px; background: rgba(255, 248, 232, .22); transition: background .25s; }
.feed-progress-segment.is-seen { background: rgba(255, 248, 232, .55); }
.feed-progress-segment.is-current { background: #f7b84b; }

/* Crossing into a neighbouring campus has to be unmistakable — the user did
 * not choose this school, so the app says whose it is. */
.feed-banner {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 92px;
  display: grid;
  gap: 2px;
  padding: 11px 20px;
  border: 1px solid rgba(247, 184, 75, .3);
  border-radius: 16px;
  background: rgba(28, 20, 36, .9);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.feed-banner.is-visible { opacity: 1; transform: translate(-50%, 0); }
.feed-banner-label { color: #f7b84b; font-size: 9px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.feed-banner-name { font: 800 17px/1.2 "Nunito", sans-serif; }

.feed-nav { position: absolute; z-index: 2; right: 20px; top: 50%; display: grid; gap: 10px; transform: translateY(-50%); }
.feed-step {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 248, 232, .18);
  border-radius: 50%;
  background: rgba(24, 18, 30, .55);
  color: #fff8e8;
  font-size: 15px;
  cursor: pointer;
  transition: transform .18s, background .18s;
}
.feed-step:hover { transform: scale(1.08); background: rgba(46, 34, 56, .82); }

@media (pointer: coarse) {
  .feed-nav { display: none; }
}

@media (max-width: 640px) {
  .feed-slide { padding: 76px 12px 16px; }
  .player { border-radius: 14px; }
  .feed-meta { padding-top: 12px; }
  .feed-title { font-size: 14px; }
  .feed-banner { top: 84px; width: calc(100% - 40px); }
}

@media (max-width: 480px) {
  #brand { top: 18px; left: 17px; gap: 8px; }
  .brand-orbit { width: 38px; height: 38px; border-width: 2px; }
  .brand-orbit::after { width: 47px; }
  #brand h1 { font-size: 26px; }
  #brand p { font-size: 8px; }
  #home-button { top: 18px; right: 15px; width: 44px; height: 44px; justify-content: center; padding: 0; }
  #home-button span:last-child { display: none; }
  #hud { bottom: 18px; max-width: calc(100vw - 30px); font-size: 10px; text-align: center; }
}

@media (max-width: 360px) {
  #hud { padding-left: 12px; padding-right: 12px; }
}

@media (min-width: 769px) and (max-height: 500px) and (orientation: landscape) {
  #brand { top: 14px; left: 18px; gap: 8px; }
  .brand-orbit { width: 39px; height: 39px; border-width: 2px; }
  .brand-orbit::after { width: 48px; }
  #brand h1 { font-size: 25px; }
  #brand p { font-size: 8px; margin-top: 3px; }
  #home-button { top: 14px; right: 16px; }
  #hud { left: auto; right: 18px; bottom: 19px; transform: none; }
  .feed-slide { padding: 62px 16px 12px; }
  .feed-meta { padding-top: 8px; }
}

#map .maplibregl-ctrl-attrib { border-radius: 10px 0 0; background: rgba(255, 248, 232, .78); font-size: 9px; }
#map .maplibregl-ctrl-attrib a { color: #55453c; }
body.feed-open .maplibregl-ctrl-attrib { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .feed-track.is-animating { transition: none; }
}
