:root {
  --duke-blue: #00539b;
  --duke-royal: #003087;
  --duke-navy: #001a57;
  --electric: #c9e2f7;
  --ink: #071a35;
  --muted: #66738b;
  --white: #fff;
  --line: #dbe5f1;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  color: var(--white);
  background: var(--duke-navy);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { font: inherit; }

.background {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(112deg, rgba(0, 20, 71, .97), rgba(0, 48, 135, .88) 50%, rgba(0, 83, 155, .66)),
    url("https://upload.wikimedia.org/wikipedia/commons/5/55/Duke_Chapel%2C_West_Campus%2C_Duke_University%2C_Durham%2C_NC_%2848960880671%29.jpg") center / cover;
}

.background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 82% 10%, rgba(95, 158, 218, .22), transparent 25rem);
}

.page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  gap: clamp(20px, 3vh, 30px);
  width: min(100% - 36px, 1440px);
  height: 100svh;
  margin: 0 auto;
  padding: clamp(30px, 5vh, 52px) 0 36px;
}

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

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 5px;
  font-size: clamp(30px, 3.7vw, 50px);
  line-height: .98;
  letter-spacing: -.05em;
}

.intro {
  margin: 0;
  color: rgba(255,255,255,.88);
  font-size: 16px;
  font-weight: 600;
}

.portfolio {
  min-height: 0;
  height: auto;
  overflow: visible;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  background: rgba(0, 20, 71, .22);
  backdrop-filter: blur(12px);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  height: 100%;
}

.project-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto auto 1fr;
  gap: 4px 10px;
  align-items: center;
  min-width: 0;
  padding: clamp(11px, 1.3vw, 17px);
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255,255,255,.98);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
  transition: color 160ms ease, transform 160ms ease;
}

.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(145deg, var(--duke-royal), var(--duke-navy));
  opacity: 0;
  transition: opacity 160ms ease;
}

.project-card > * { position: relative; z-index: 1; }

.project-card:hover, .project-card:focus-visible { z-index: 1; color: white; transform: translateY(-2px); }
.project-card:hover::before, .project-card:focus-visible::before { opacity: 1; }
.project-card:focus-visible { outline: 3px solid var(--electric); outline-offset: -3px; }

.project-number {
  position: absolute;
  top: 12px;
  right: 13px;
  color: #9ba9ba;
  font-size: 9px;
  font-weight: 900;
}

.icon {
  grid-column: 1;
  grid-row: 2 / 4;
  display: grid;
  place-items: center;
  width: clamp(35px, 3.5vw, 45px);
  height: clamp(35px, 3.5vw, 45px);
  border-radius: 10px;
  color: var(--duke-royal);
  background: #e9f2fc;
  font-size: clamp(18px, 2vw, 25px);
  font-weight: 800;
}

.code-icon { font-size: 14px; }
.category { grid-column: 2 / 4; grid-row: 2; color: var(--duke-blue); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.project-card strong { grid-column: 2; grid-row: 3; overflow: hidden; font-size: clamp(16px, 1.45vw, 20px); line-height: 1.15; text-overflow: ellipsis; }
.view { grid-column: 3; grid-row: 3; color: var(--duke-blue); font-size: 13px; font-weight: 900; }
.project-card:hover :is(.project-number, .category, .view), .project-card:focus-visible :is(.project-number, .category, .view) { color: rgba(255,255,255,.7); }
.project-card:hover .icon, .project-card:focus-visible .icon {
  color: var(--duke-royal);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(201, 226, 247, .28);
}

.video-card {
  display: block;
  overflow: hidden;
  padding: 0;
  background: rgba(255,255,255,.98);
}

.video-card::before { display: none; }
.video-card:hover { transform: translateY(-2px); }

.video-launch {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto auto 1fr;
  gap: 4px 10px;
  align-items: center;
  width: 100%;
  height: 100%;
  border: 0;
  padding: clamp(11px, 1.3vw, 17px);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  isolation: isolate;
}

.video-launch::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(0,20,71,.94), rgba(0,48,135,.7) 58%, rgba(0,0,0,.25)),
    url("https://i.ytimg.com/vi/P6w0EGmIHvI/hqdefault.jpg") center 45% / cover;
  transition: opacity 220ms ease;
}

.video-launch:hover::before,
.video-launch:focus-visible::before { opacity: 1; }

.video-launch:focus-visible { outline: 3px solid var(--electric); outline-offset: -3px; }
.video-launch > :not(.preview-progress) { position: relative; z-index: 1; }
.video-launch .project-number { position: absolute; z-index: 1; }
.video-launch .icon { grid-column: 1; grid-row: 2 / 4; }
.video-launch .category { grid-column: 2 / 4; grid-row: 2; }
.video-launch > strong { grid-column: 2; grid-row: 3; overflow: hidden; font-size: clamp(16px, 1.45vw, 20px); line-height: 1.15; text-overflow: ellipsis; }
.video-launch .view { grid-column: 3; grid-row: 3; }

.video-icon-hover { display: none; font-size: .72em; transform: translateX(1px); }
.video-launch:hover .video-icon-default,
.video-launch:focus-visible .video-icon-default { display: none; }
.video-launch:hover .video-icon-hover,
.video-launch:focus-visible .video-icon-hover { display: inline; }

.video-launch:hover,
.video-launch:focus-visible { color: var(--white); }
.video-launch:hover :is(.project-number, .category, .view),
.video-launch:focus-visible :is(.project-number, .category, .view) { color: rgba(255,255,255,.78); }
.video-launch:hover .icon,
.video-launch:focus-visible .icon { color: var(--duke-royal); background: var(--white); box-shadow: 0 0 0 4px rgba(255,255,255,.18); }

.preview-progress {
  position: absolute;
  right: 12px;
  bottom: 9px;
  left: 12px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255,255,255,.3);
  opacity: 0;
  transition: opacity 180ms ease;
}

.preview-progress i { display: block; width: 28%; height: 100%; background: #55b8ff; }
.video-launch:hover .preview-progress,
.video-launch:focus-visible .preview-progress { opacity: 1; }

.video-player { position: absolute; inset: 0; z-index: 3; background: #000; }
.video-player iframe { display: block; width: 100%; height: 100%; border: 0; }

.player-controls {
  position: absolute;
  right: 6px;
  bottom: 6px;
  left: 6px;
  display: grid;
  grid-template-columns: 26px 1fr 26px;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px;
  color: var(--white);
  background: rgba(0,20,71,.86);
  backdrop-filter: blur(8px);
}

.player-controls button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--white);
  background: rgba(255,255,255,.14);
  font-size: 10px;
  cursor: pointer;
}

.player-controls span { overflow: hidden; font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.player-close { font-size: 17px !important; }

.human-first {
  color: var(--duke-navy);
  background:
    radial-gradient(circle at 88% 8%, rgba(255,255,255,.72), transparent 38%),
    linear-gradient(135deg, #e4f2fd 0%, #bad9f3 52%, #91bfe6 100%);
  box-shadow:
    inset 4px 0 0 #1769ad,
    inset 0 0 0 1px rgba(0, 48, 135, .18),
    0 8px 20px rgba(0, 48, 135, .16);
}

.human-first .icon {
  color: var(--duke-royal);
  background: var(--white);
  box-shadow: 0 5px 14px rgba(0, 48, 135, .14);
}

.human-first :is(.project-number, .category, .view) { color: #1d609b; }
.human-first::before { background: linear-gradient(145deg, #00539b, #003087); }

.eyebrow { margin: 0 0 8px; color: var(--duke-blue); font-size: 9px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }

.project-dialog {
  width: min(620px, calc(100% - 28px));
  padding: 30px;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  box-shadow: 0 35px 100px rgba(0, 10, 42, .45);
}
.project-dialog::backdrop { background: rgba(0, 12, 44, .76); backdrop-filter: blur(8px); }
.project-dialog h2 { margin-bottom: 10px; font-size: 29px; letter-spacing: -.04em; }
.dialog-summary { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.close-dialog { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; color: var(--ink); background: #edf3f9; font-size: 22px; cursor: pointer; }
.project-story { display: grid; gap: 1px; margin: 20px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--line); }
.project-story div { display: grid; grid-template-columns: 95px 1fr; gap: 14px; padding: 12px; background: white; }
.project-story span { color: var(--duke-blue); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.project-story p { margin: 0; font-size: 11px; line-height: 1.45; }
.dialog-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.dialog-footer > span { color: var(--muted); font-size: 9px; font-weight: 700; }
.dialog-footer a { padding: 10px 12px; border-radius: 8px; color: white; background: var(--duke-royal); font-size: 10px; font-weight: 900; text-decoration: none; }

@media (max-width: 600px) {
  .page { width: min(100% - 20px, 1440px); padding: 24px 0 10px; gap: 20px; }
  .hero { align-items: center; }
  h1 { font-size: clamp(28px, 8vw, 40px); }
  .intro { font-size: 10px; }
  .portfolio { height: auto; padding: 8px; }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(0, 1fr)); }
  .project-grid { gap: 8px; }
  .project-card { grid-template-rows: auto auto; padding: 8px 10px; gap: 2px 8px; border-radius: 9px; }
  .video-card { padding: 0; }
  .video-launch { grid-template-rows: auto auto; padding: 8px 10px; gap: 2px 8px; }
  .project-number { top: 6px; right: 7px; font-size: 7px; }
  .icon { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 8px; font-size: 18px; }
  .code-icon { font-size: 10px; }
  .category { grid-row: 1; font-size: 7px; }
  .project-card strong {
    display: -webkit-box;
    grid-row: 2;
    overflow: hidden;
    font-size: clamp(11px, 3vw, 14px);
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .view { grid-row: 2; font-size: 11px; }
}

@media (max-width: 600px) {
  body { overflow-x: hidden; overflow-y: auto; }

  .background {
    background-position: 58% center;
  }

  .page {
    width: calc(100% - 24px);
    height: auto;
    min-height: 100svh;
    padding: 28px 0 36px;
    gap: 24px;
  }

  h1 {
    max-width: 350px;
    margin-bottom: 8px;
    font-size: clamp(34px, 10vw, 42px);
    line-height: .95;
  }

  .intro { font-size: 14px; }

  .portfolio {
    height: auto;
    padding: 8px;
    border-radius: 16px;
  }

  .project-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 8px;
    height: auto;
  }

  .project-card {
    grid-template-rows: auto auto;
    min-height: 84px;
    padding: 13px 15px;
    gap: 3px 12px;
    border-radius: 10px;
  }

  .video-card { padding: 0; }
  .video-launch { grid-template-rows: auto auto; padding: 13px 15px; gap: 3px 12px; }

  .project-number {
    top: 9px;
    right: 10px;
    font-size: 8px;
  }

  .icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 21px;
  }

  .code-icon { font-size: 13px; }
  .category { font-size: 10px; }
  .project-card strong { font-size: 17px; }
  .view { padding-right: 4px; font-size: 14px; }
}

@media (max-height: 600px) {
  .page { padding: 16px 0 8px; gap: 12px; }
  h1 { font-size: 30px; }
  .intro { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; } }
