/* ==========================================================================
   John Michael E. Jabuen — portfolio styles
   1. Tokens   2. Base   3. Layout & type   4. Components   5. Sections
   6. Dialogs  7. Responsive   8. Motion preferences
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Colour */
  --bg: #07090d;
  --surface: #0e1117;
  --surface-2: #141823;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #f3f4f6;
  --muted: #a7aebd;
  --dim: #858d9e;
  --accent: #36efb0;
  --accent-ink: #04130d;
  --accent-soft: rgba(54, 239, 176, .1);
  --accent-line: rgba(54, 239, 176, .28);
  --blue: #67d9ff;
  --blue-soft: rgba(103, 217, 255, .1);
  --danger: #ff8a8a;

  /* Type */
  --sans: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, serif;
  --mono: "DM Mono", ui-monospace, Menlo, monospace;
  --fs-xs: .75rem;                                   /* 12px labels */
  --fs-sm: .875rem;                                  /* 14px meta */
  --fs-base: 1rem;                                   /* 16px body */
  --fs-lg: clamp(1.0625rem, .35vw + 1rem, 1.25rem);  /* 17–20px lead */
  --fs-h3: clamp(1.125rem, .5vw + 1rem, 1.375rem);
  --fs-h2: clamp(2rem, 3vw + 1rem, 3.25rem);
  --fs-h1: clamp(2.5rem, 4.6vw + 1rem, 4.75rem);

  /* Space (4px base) */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem;
  --s-6: 2rem; --s-7: 3rem; --s-8: 4rem;
  --section-y: clamp(4rem, 8vw, 7rem);
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --container: 1200px;

  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 8px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base)/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -.02em; font-weight: 700; text-wrap: balance; }
em { font-family: var(--serif); font-style: italic; font-weight: 700; letter-spacing: -.01em; }
strong { font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link {
  position: absolute; left: var(--s-4); top: var(--s-2); z-index: 100; transform: translateY(-200%);
  background: var(--accent); color: var(--accent-ink); padding: var(--s-2) var(--s-4); border-radius: 8px; font-weight: 700;
}
.skip-link:focus { transform: none; }

/* 3. Layout & type ---------------------------------------------------------- */
.container { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: var(--section-y) 0; border-top: 1px solid var(--border); }

.section-head { max-width: 720px; margin-bottom: var(--s-7); }
.section-head h2 { font-size: var(--fs-h2); margin: var(--s-3) 0 var(--s-4); }
.section-head p:not(.eyebrow) { color: var(--muted); font-size: var(--fs-lg); }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-3);
  font: 500 var(--fs-xs)/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
}
.eyebrow::before { content: ""; width: 24px; height: 1px; background: currentColor; }
.eyebrow-blue { color: var(--blue); }
.lead { font-size: var(--fs-lg); color: var(--muted); }
.meta { color: var(--dim); font-size: var(--fs-sm); }
.sub-head { font-size: var(--fs-h3); margin: var(--s-7) 0 var(--s-5); }

/* 4. Components ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 48px; padding: 0 var(--s-5); border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: .9375rem; line-height: 1; white-space: nowrap;
  transition: background-color .2s, border-color .2s, color .2s, transform .2s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #5cf5c2; }
.btn-ghost { border-color: var(--border-strong); background: rgba(255, 255, 255, .02); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { min-height: 40px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .65; cursor: progress; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(1.25rem, 2.5vw, 2rem);
}
.card h3 { font-size: var(--fs-h3); margin: var(--s-2) 0 var(--s-3); }
.card p { color: var(--muted); }
.card .meta { margin: calc(-1 * var(--s-2)) 0 var(--s-4); }

.tag { font: 500 var(--fs-xs)/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.card .tag { color: var(--accent); }
.tag-blue, .card .tag-blue { color: var(--blue); }
.tag-muted, .card .tag-muted { color: var(--dim); }

.text-link {
  display: inline-flex; align-items: center; gap: .35em; margin-top: var(--s-4);
  color: var(--accent); font-weight: 700; font-size: var(--fs-sm);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.text-link:hover { border-color: currentColor; }
.link-row { display: flex; flex-wrap: wrap; gap: 0 var(--s-5); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); }
.chips li { padding: var(--s-1) var(--s-3); border: 1px solid var(--border-strong); border-radius: 999px; font: 500 var(--fs-xs)/1.6 var(--mono); color: var(--text); }

.checklist { display: grid; gap: var(--s-2); color: var(--muted); }
.checklist li { position: relative; padding-left: 1.5rem; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--blue); font-weight: 700; }

.notice { padding: var(--s-5); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: rgba(7, 9, 13, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s-5); }
.brand { font: 700 1.125rem/1 var(--mono); letter-spacing: .02em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: var(--s-5); font-size: var(--fs-sm); font-weight: 600; }
.site-nav a:not(.btn) { color: var(--muted); padding: var(--s-2) 0; transition: color .2s; }
.site-nav a:not(.btn):hover { color: var(--text); }
.menu-toggle { display: none; width: 44px; height: 44px; border: 1px solid var(--border-strong); border-radius: 12px; background: transparent; place-items: center; }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
.menu-toggle[aria-expanded="true"] .menu-icon { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-icon::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }

/* 5. Sections --------------------------------------------------------------- */

/* Hero */
.hero { padding: clamp(3rem, 7vw, 6rem) 0 var(--section-y); position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 400px at 85% 20%, rgba(54, 239, 176, .08), transparent 70%),
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 56px 56px;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr); gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.hero h1 { font-size: var(--fs-h1); line-height: 1.04; letter-spacing: -.035em; margin: var(--s-4) 0 var(--s-5); max-width: 14ch; }
.hero h1 em { color: var(--accent); }
.hero .lead { max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }
.hero-facts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-6); color: var(--dim); font-size: var(--fs-sm); }
.hero-facts strong { color: var(--text); }
.hero-photo { position: relative; border-radius: 22px; overflow: hidden; border: 1px solid var(--accent-line); box-shadow: var(--shadow); aspect-ratio: 4 / 5; max-width: 400px; justify-self: end; width: 100%; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 12%; }
.hero-photo figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: var(--s-6) var(--s-4) var(--s-4);
  background: linear-gradient(transparent, rgba(7, 9, 13, .92)); display: grid; gap: 2px; font-size: var(--fs-sm);
}
.hero-photo figcaption span { color: var(--muted); font-size: var(--fs-xs); font-family: var(--mono); letter-spacing: .04em; }

/* Video work */
.section-work { background: radial-gradient(800px 400px at 10% 0, rgba(54, 239, 176, .05), transparent 70%); }
.filters { display: flex; gap: var(--s-2); margin-bottom: var(--s-5); overflow-x: auto; scrollbar-width: none; padding: 2px; margin-inline: -2px; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; min-height: 40px; padding: 0 var(--s-4); border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: .2s;
}
.filter span { margin-left: .4em; color: var(--dim); font: 500 var(--fs-xs) var(--mono); }
.filter:hover { color: var(--text); border-color: var(--accent-line); }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.filter[aria-pressed="true"] span { color: var(--accent-ink); opacity: .7; }

.video-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(.75rem, 1.5vw, 1.25rem); }
.video-card {
  display: flex; flex-direction: column; width: 100%; padding: 0; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.video-card:hover { transform: translateY(-4px); border-color: var(--accent-line); box-shadow: var(--shadow); }
.video-card:focus-visible { outline-offset: 2px; border-radius: var(--radius); }
.vc-thumb { position: relative; aspect-ratio: 3 / 4; background: linear-gradient(160deg, #18202c, #0b0e14); overflow: hidden; }
.vc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; transition: transform .4s; }
.video-card:hover .vc-thumb img { transform: scale(1.04); }
.vc-thumb.is-landscape img { object-fit: contain; }
.vc-play {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(7, 9, 13, .6); border: 1px solid rgba(255, 255, 255, .5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background-color .2s, transform .2s;
}
.vc-play::before { content: ""; margin-left: 3px; border-left: 14px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }
.video-card:hover .vc-play { background: var(--accent); transform: scale(1.06); }
.video-card:hover .vc-play::before { border-left-color: var(--accent-ink); }
.vc-badges { position: absolute; left: var(--s-2); top: var(--s-2); right: var(--s-2); display: flex; flex-wrap: wrap; gap: var(--s-1); }
.badge { padding: 3px 8px; border-radius: 999px; font: 500 .6875rem/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; background: rgba(7, 9, 13, .75); border: 1px solid var(--border-strong); color: var(--text); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.badge-client { color: var(--accent); border-color: var(--accent-line); }
.vc-body { padding: var(--s-3) var(--s-4) var(--s-4); display: grid; gap: var(--s-1); }
.vc-title { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.vc-desc { font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more-row { display: flex; justify-content: center; margin-top: var(--s-6); }
.more-row:has(> [hidden]) { display: none; }

/* Teaching */
.award-feature { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(1.25rem, 4vw, 3rem); align-items: center; border-color: rgba(103, 217, 255, .22); background: radial-gradient(500px 300px at 100% 0, var(--blue-soft), transparent 70%), var(--surface); }
.award-copy h3 { font-size: clamp(1.5rem, 2vw + 1rem, 2.25rem); }
.award-copy p:not(.tag) { max-width: 36rem; }
.doc-thumb { display: block; border-radius: var(--radius-sm); overflow: hidden; background: #fff; box-shadow: var(--shadow); transition: transform .25s; }
.doc-thumb:hover { transform: translateY(-3px); }

.award-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
.award-card { width: 100%; padding: 0; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .2s, transform .2s; }
.award-card:hover { border-color: rgba(103, 217, 255, .35); transform: translateY(-3px); }
.award-card img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: top; background: #f5efe6; }
.award-card span { display: block; padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); font-weight: 600; }

.teach-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); margin-top: var(--s-7); }

.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.photo-grid button, .media-btn { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .4s; }
.photo-grid button:hover img, .media-btn:hover img { transform: scale(1.03); }
.media-btn img { width: 100%; transition: transform .4s; }

/* Engineering */
.case-study { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
.case-media { display: grid; gap: var(--s-3); }
.case-media > .media-btn img { aspect-ratio: 16 / 9; object-fit: cover; }
.case-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.case-thumbs .media-btn { border-radius: var(--radius-sm); }
.case-thumbs img { aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.case-copy h3 { font-size: clamp(1.25rem, 1vw + 1rem, 1.625rem); line-height: 1.25; }
.case-facts { display: grid; gap: var(--s-4); margin: var(--s-5) 0 var(--s-2); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.case-facts dt { font: 500 var(--fs-xs)/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: var(--s-1); }
.case-facts dd { color: var(--muted); }
.eng-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); margin-top: var(--s-4); }

/* About */
.about-grid { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.about-photo { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); max-width: 380px; }
.about-copy h2 { font-size: var(--fs-h2); margin: var(--s-3) 0 var(--s-5); }
.about-copy p:not(.eyebrow) { color: var(--muted); max-width: 40rem; }
.about-copy p + p { margin-top: var(--s-4); }
.about-copy .lead strong { color: var(--text); }
.pillars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); margin-top: var(--s-6); }
.pillars li { padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); display: grid; gap: 2px; }
.pillars strong { color: var(--accent); font: 500 var(--fs-xs)/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.pillars span { font-size: var(--fs-sm); }

/* Contact */
.section-contact { background: radial-gradient(700px 400px at 20% 100%, rgba(54, 239, 176, .07), transparent 70%); }
.contact-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.contact-copy h2 { font-size: var(--fs-h2); margin: var(--s-3) 0 var(--s-4); }
.contact-copy > p:not(.eyebrow) { color: var(--muted); font-size: var(--fs-lg); }
.contact-links { display: grid; gap: var(--s-2); margin-top: var(--s-6); }
.contact-links a {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); min-height: 52px;
  padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-weight: 600; font-size: var(--fs-sm); overflow-wrap: anywhere; transition: border-color .2s;
}
.contact-links a:hover { border-color: var(--accent-line); }
.contact-links span { color: var(--dim); font: 500 var(--fs-xs) var(--mono); letter-spacing: .08em; text-transform: uppercase; flex: none; }

.contact-form { display: grid; gap: var(--s-4); }
.field { display: grid; gap: var(--s-2); }
.field label { font-weight: 600; font-size: var(--fs-sm); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border-strong); font-size: 1rem; /* 16px stops iOS zoom */
  transition: border-color .2s, box-shadow .2s;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: var(--s-7); }
.field textarea { resize: vertical; min-height: 140px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: var(--fs-sm); min-height: 0; }
.field-error:empty { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-status:empty { display: none; }
.form-status { padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm); font-size: var(--fs-sm); background: var(--surface-2); color: var(--muted); }
.form-status.is-success { background: var(--accent-soft); color: var(--accent); }
.form-status.is-error { background: rgba(255, 138, 138, .1); color: var(--danger); }
.form-status a { text-decoration: underline; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: var(--s-6) 0; color: var(--dim); font-size: var(--fs-sm); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3) var(--s-5); }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.footer-links a:hover { color: var(--text); }

/* 6. Dialogs ---------------------------------------------------------------- */
.dialog {
  padding: 0; border: 1px solid var(--accent-line); border-radius: 18px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); overflow: hidden; max-width: none; max-height: calc(100dvh - 2rem);
}
.dialog::backdrop { background: rgba(0, 0, 0, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.dialog[open] { display: flex; flex-direction: column; }
.dialog-close {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(7, 9, 13, .75); font-size: 1.5rem; line-height: 1;
}
.dialog-close:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Video player. Google Drive's embedded player draws its own controls and needs
   width to lay them out, so the frame keeps a usable minimum width and Drive
   letterboxes the video inside it. */
.video-dialog {
  /* Portrait: as wide as the screen height allows, capped at 460px. */
  width: min(calc(100vw - 2rem), max(340px, min(460px, (100dvh - 15rem) * 9 / 16)));
}
.video-dialog.is-landscape { width: min(calc(100vw - 2rem), 960px); }
.vd-frame { position: relative; width: 100%; aspect-ratio: 9 / 16; flex: 0 1 auto; min-height: min(320px, 55dvh); background: #000; }
.video-dialog.is-landscape .vd-frame { aspect-ratio: 16 / 9; min-height: 0; }
.vd-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vd-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font: 500 var(--fs-xs) var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.vd-info { flex: none; padding: var(--s-4) 68px var(--s-5) var(--s-5); display: grid; gap: var(--s-1); }
/* Close button sits in the caption so it never covers Drive's own buttons. */
.video-dialog .dialog-close { top: auto; bottom: var(--s-4); right: var(--s-4); }
.vd-info h3 { font-size: 1.125rem; }
.vd-info p:not(.tag) { color: var(--muted); font-size: var(--fs-sm); }
.vd-info .text-link { margin-top: var(--s-2); }

/* Image viewer */
.image-dialog { width: min(calc(100vw - 2rem), 1000px); background: #0b0d12; }
.image-dialog img { flex: 0 1 auto; min-height: 0; width: 100%; height: auto; max-height: calc(100dvh - 7rem); object-fit: contain; background: #050608; }
.iv-bar { flex: none; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-2) var(--s-4); padding: var(--s-3) var(--s-5); font-size: var(--fs-sm); }
.iv-bar .text-link { margin: 0; }

/* 7. Responsive ------------------------------------------------------------- */
@media (max-width: 1080px) {
  .video-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .eng-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eng-grid > :last-child { grid-column: 1 / -1; }
  .case-study { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .menu-toggle { display: grid; }
  .site-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0;
    padding: var(--s-2) var(--gutter) var(--s-5); background: rgba(7, 9, 13, .97); border-bottom: 1px solid var(--border);
    font-size: 1rem; visibility: hidden; opacity: 0; transform: translateY(-8px); transition: opacity .2s, transform .2s, visibility 0s .2s;
  }
  .site-nav.is-open { visibility: visible; opacity: 1; transform: none; transition: opacity .2s, transform .2s; }
  .site-nav a:not(.btn) { padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
  .site-nav .btn { margin-top: var(--s-4); min-height: 48px; }

  .hero-grid { grid-template-columns: 1fr; }
  .hero-photo { order: -1; justify-self: start; width: 112px; aspect-ratio: 1; border-radius: 50%; }
  .hero-photo img { object-position: center 18%; }
  .hero-photo figcaption { display: none; }
  .hero h1 { max-width: 16ch; }

  .award-feature { grid-template-columns: 1fr; }
  .award-feature .doc-thumb { max-width: 320px; }
  .award-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .teach-grid, .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .about-photo { max-width: 300px; }
}

@media (max-width: 640px) {
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vc-body { padding: var(--s-3); }
  .vc-title { font-size: .9375rem; }
  .vc-desc { font-size: .8125rem; }
  .vc-play { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .eng-grid, .pillars { grid-template-columns: 1fr; }
  .hero-actions .btn { flex: 1 1 100%; }
  .section-head { margin-bottom: var(--s-6); }
  .contact-links a { flex-direction: column; align-items: flex-start; gap: 2px; }

  /* Phone video player: use the full width so Drive's controls fit. */
  .dialog { max-height: calc(100dvh - 1rem); border-radius: 14px; }
  .video-dialog, .video-dialog.is-landscape, .image-dialog { width: calc(100vw - 1rem); }
  .vd-info { padding: var(--s-3) 64px var(--s-4) var(--s-4); }
}

/* Landscape phones: caption beside the video so the frame keeps its height. */
@media (orientation: landscape) and (max-height: 560px) {
  .video-dialog:not(.is-landscape)[open] { flex-direction: row; width: min(calc(100vw - 1rem), 760px); height: calc(100dvh - 1rem); }
  .video-dialog:not(.is-landscape) .vd-frame { width: min(55%, 420px); height: 100%; aspect-ratio: auto; min-height: 0; flex: none; }
  .video-dialog:not(.is-landscape) .vd-info { flex: 1; align-content: center; padding: var(--s-5) 64px var(--s-5) var(--s-5); }
  .video-dialog:not(.is-landscape) .dialog-close { top: 10px; bottom: auto; right: 10px; }
}

/* 8. Motion preferences ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .video-card:hover, .award-card:hover, .doc-thumb:hover { transform: none; }
}
