/* ============================================================
   AL-EK — shared styles
   (dark theme; ported from hybridsurface.com)
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --max-width: 1000px;
  --gutter: 2rem;
  --content-width: calc(1000px - 4rem);
  --nav-height: 56px;
  --fg: #ffffff;
  --muted: #a0a0a0;
  --bg: #000000;
  --panel: #111111;
  --panel-hover: #1a1a1a;
  --border: #222222;
  --accent: #6BB4E8;
}

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", "InterVariable", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Roboto", "Helvetica Neue", sans-serif;
  font-weight: 200;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.4;
}
@supports (font-variation-settings: normal) {
  body { font-family: "InterVariable", "Inter", sans-serif; }
}

a { color: inherit; text-decoration: none; }
a:hover { color: inherit; text-decoration: underline; }

/* ---- home hero (matches the original: left-justified, logo 450% / sublogo 135%) ---- */
.hero { text-align: left; max-width: var(--content-width); margin: 0.5rem auto 2rem auto; font-size: calc(20px + 0.390625vw); line-height: 1.1; }
.hero .logo { font-weight: 300; font-size: 450%; }
.hero .sublogo { display: inline-block; margin-top: 0.1rem; font-weight: 300; font-size: 135%; color: var(--fg); }

/* ---- top navigation ---- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: var(--nav-height);
  display: flex;
  align-items: center;
}
.nav-inner .brand {
  font-weight: 400;
  letter-spacing: 0.12em;
  font-size: 1.05rem;
  margin-right: 1.5rem;
}
.nav-inner .brand:hover { text-decoration: none; color: var(--fg); }
.nav-toggle {
  display: none;
  background: none;
  border: 0;
  color: var(--fg);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  margin-left: 0.75rem;
}

/* right-aligned social icon links */
.nav-social {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.nav-social a { display: inline-flex; color: var(--muted); }
.nav-social a:hover { color: var(--fg); text-decoration: none; }
.nav-social svg { width: 1.25rem; height: 1.25rem; display: block; }
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nav-links > li { display: flex; align-items: center; }

/* top-level links and group labels share styling */
.nav-links a,
.nav-group-label {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.nav-links a:hover,
.nav-group-label:hover { color: var(--fg); text-decoration: none; }
.nav-links > li > a.active,
.nav-group-label.active { color: var(--fg); border-bottom-color: var(--fg); }
.nav-group-label::after { content: "▾"; font-size: 0.7em; line-height: 1; }

/* desktop dropdown */
.nav-group { position: relative; }
.nav-dropdown {
  list-style: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 110;
}
.nav-group:hover .nav-dropdown,
.nav-group.open .nav-dropdown { display: block; }
.nav-dropdown li { display: block; }
.nav-dropdown a {
  display: block;
  width: 100%;
  white-space: nowrap;
  padding: 0.5rem 1rem;
  border-bottom: 0;
}
.nav-dropdown a:hover { background: var(--panel-hover); color: var(--fg); }
.nav-dropdown a.active { color: var(--fg); font-weight: 500; }

/* ---- in-page section menu ---- */
.section-menu {
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.section-menu-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.6rem var(--gutter);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
}
.section-menu-inner a { color: var(--muted); }
.section-menu-inner a:hover { color: var(--fg); text-decoration: none; }

/* ---- layout ---- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--gutter);
}

/* anchored blocks clear the sticky nav when scrolled to */
[id] { scroll-margin-top: calc(var(--nav-height) + 1rem); }

.loading, .error {
  text-align: center;
  padding: 2rem;
  font-size: 1.1rem;
  color: var(--muted);
}
.error { color: #e06c6c; }

/* ---- media blocks ---- */
.video-container,
.image-container,
.embed-block,
.grid-block {
  width: 100%;
  margin-bottom: 2rem;
  display: block;
}
.video-container { position: relative; min-height: 200px; background-color: var(--panel); }

.video-container video,
.image-container img {
  width: 100%;
  max-width: var(--content-width);
  height: auto;
  display: block;
  margin: 0 auto;
}

.caption {
  padding: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  width: 100%;
}

@media (orientation: landscape) {
  .video-container video,
  .image-container img {
    max-height: 90vh;
    max-width: var(--content-width);
    width: auto;
    margin: 0 auto !important;
  }
}

/* ---- external-link overlay ---- */
.content-link { display: block; color: inherit; position: relative; overflow: hidden; }
.link-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  font-size: 1rem;
  font-weight: 400;
  text-align: center;
  padding: 1rem;
  z-index: 10;
}
.content-link:hover .link-overlay { opacity: 1; }

/* ---- html / text fragments ---- */
.html-content,
.text-content {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto 2rem auto;
}
.text-content {
  padding: 1rem;
  background-color: var(--panel);
  border-radius: 8px;
  white-space: pre-wrap;
}
.html-content h1, .html-content h2, .html-content h3,
.html-content h4, .html-content h5, .html-content h6 { margin-bottom: 1rem; font-weight: 300; }
.html-content p { margin-bottom: 1rem; }
.html-content a { color: inherit; text-decoration: none; }
.html-content a:hover { color: inherit; text-decoration: underline; }

/* ---- section heading ---- */
.section-heading {
  max-width: var(--content-width);
  margin: 2.5rem auto 1.5rem auto;
  text-align: left;
}
.section-heading h1,
.section-heading h2,
.section-heading h3 {
  font-weight: 300;
  font-style: italic;
  letter-spacing: 0.02em;
}
.section-heading h1 { font-size: 2.4rem; margin-top: 1rem; }   /* year */
.section-heading h2 { font-size: 1.5rem; }                     /* show */
.section-heading h3 { font-size: 1.15rem; }                    /* sub-section */
.section-heading .subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ---- button link ---- */
.link-block { max-width: var(--content-width); margin: 0 auto 2rem auto; text-align: center; }
.button-link {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--fg);
  border-radius: 999px;
  font-size: 0.9rem;
}
.button-link:hover { background: var(--fg); color: var(--bg); text-decoration: none; }

/* ---- external-link affordance (box + diagonal arrow) ---- */
.external-link { display: inline-flex; align-items: center; gap: 0.3em; }
.ext-icon { display: inline-flex; }
.ext-icon svg { display: block; }

/* ---- citation / abstract block ---- */
.citation-block { max-width: var(--content-width); margin: 0 auto 2rem auto; }
.citation-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.citation-block .abstract { margin-bottom: 1.75rem; }
.citation-block .abstract p { margin: 0; }
.citation-text {
  background: var(--panel);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}
.citation-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 0.7rem;
}
.copy-btn {
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--fg);
}
.copy-btn:hover { background: var(--panel-hover); }
.copy-btn.copied { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.citation-actions .external-link { font-size: 0.85rem; color: var(--muted); }
.citation-actions .external-link:hover { color: var(--fg); }

/* ---- inline PDF viewer ---- */
.pdf-block { max-width: var(--content-width); margin: 0 auto 2rem auto; }
.pdf-head { margin-bottom: 0.5rem; }
.pdf-head .external-link { font-size: 0.9rem; font-weight: 400; }
.pdf-frame {
  width: 100%;
  height: 1008px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.pdf-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---- responsive video embeds (Vimeo / YouTube) ---- */
.embed-block { max-width: var(--content-width); margin-left: auto; margin-right: auto; }
.embed-container { position: relative; width: 100%; height: 0; overflow: hidden; }
.embed-16x9 { padding-bottom: 56.25%; }
.embed-4x3  { padding-bottom: 75%; }
.embed-1x1  { padding-bottom: 100%; }
.embed-9x16 { padding-bottom: 177.78%; }
.embed-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- Instagram-style grid ---- */
.grid-block { max-width: var(--content-width); margin-left: auto; margin-right: auto; }
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: 4px;
}
.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
}
.grid-item img,
.grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.grid-item:hover img,
.grid-item:hover video { transform: scale(1.04); }
.grid-item.is-video::after {
  content: "▶";
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  color: #fff;
  font-size: 0.8rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.grid-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  opacity: 0;
  transition: opacity 0.2s ease;
}
.grid-item:hover .grid-caption { opacity: 1; }

/* ---- lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.lightbox.open { display: flex; }
.lightbox-stage { display: flex; align-items: center; justify-content: center; }
.lightbox img,
.lightbox video { max-width: 92vw; max-height: 82vh; display: block; }
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: 0;
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: #fff;
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem 1rem;
  opacity: 0.7;
  z-index: 2;
}
.lightbox-nav:hover { opacity: 1; }
.lightbox-prev { left: 0.25rem; }
.lightbox-next { right: 0.25rem; }
.lightbox-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.25rem;
  text-align: center;
  color: #fff;
  font-size: 0.9rem;
  font-style: italic;
  padding: 0 3.5rem;
  pointer-events: none;
}
.zoomable { cursor: pointer; }

/* ---- preview mode indicator (?hidden=<key>) ---- */
body.preview-mode::after {
  content: "preview";
  position: fixed;
  bottom: 0.6rem;
  left: 0.6rem;
  z-index: 1000;
  background: #600000;
  color: #fff;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  opacity: 0.85;
  pointer-events: none;
}

@media (max-width: 480px) {
  .lightbox-nav { font-size: 2rem; padding: 0.5rem 0.5rem; }
  .lightbox-caption { padding: 0 2.5rem; font-size: 0.8rem; }
}

/* ---- responsive ---- */
@media (max-width: 768px) {
  :root { --gutter: 1rem; }
  .nav-toggle { display: block; }
  /* menu floats over content as a dropdown panel — opening it never
     changes the bar height (no layout jump) */
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links > li { display: block; width: 100%; }
  .nav-links a,
  .nav-group-label {
    width: 100%;
    padding: 0.8rem var(--gutter);
    font-size: 1rem;
    border-bottom: 0;
  }
  .nav-links > li > a.active,
  .nav-group-label.active { color: var(--fg); font-weight: 400; border-bottom: 0; }
  .nav-group { position: static; }
  .nav-group-label { justify-content: space-between; }
  .nav-group-label::after { margin-left: auto; }
  /* groups render inline and expanded inside the panel */
  .nav-dropdown {
    position: static;
    display: block;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    background: #0a0a0a;
  }
  .nav-dropdown a { padding-left: calc(var(--gutter) + 1rem); }
  .grid { gap: 2px; }
  .pdf-frame { height: 70vh; }
  .video-container, .image-container, .embed-block, .grid-block, .pdf-block { margin-bottom: 1rem; }
}

@media (max-width: 480px) {
  :root { --gutter: 0.75rem; }
  .grid { grid-template-columns: repeat(min(var(--cols, 3), 3), 1fr); }
}
