/* ==========================================================================
   Components: navigation, laptop mockup, screen content, tags
   ========================================================================== */

/* -------------------------------------------------------------------------- */
/* Floating top bar                                                           */
/* -------------------------------------------------------------------------- */

.topbar {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  z-index: 50;
  width: min(100% - 24px, 940px);
  height: var(--topbar-h);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 8px 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--nav-bg);
  box-shadow: var(--nav-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  transition:
    background-color var(--dur-2) ease,
    border-color var(--dur-2) ease;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand__mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 3px var(--line);
}

.nav__list {
  display: flex;
  gap: 2px;
}

.nav__link {
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-s);
  color: var(--text-muted);
  white-space: nowrap;
  transition:
    color var(--dur-2) ease,
    background-color var(--dur-2) ease;
}

.nav__link:hover {
  color: var(--text);
}

.nav__link.is-active {
  color: var(--text);
  background: var(--line);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  transition:
    color var(--dur-2) ease,
    background-color var(--dur-2) ease;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  color: var(--text);
  background: var(--line);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Theme toggle shows the sun in dark mode and the moon in light mode. */
.theme-icon--moon,
:root[data-theme="light"] .theme-icon--sun {
  display: none;
}

:root[data-theme="light"] .theme-icon--moon {
  display: inline-flex;
}

/* -------------------------------------------------------------------------- */
/* Language menu                                                              */
/* -------------------------------------------------------------------------- */

.lang {
  position: relative;
}

.lang__menu {
  position: absolute;
  top: calc(100% + 12px);
  right: -4px;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--bg-elev);
  box-shadow: var(--menu-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition:
    opacity var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-out),
    visibility 0s linear var(--dur-2);
}

.lang.is-open .lang__menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.lang__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  font-size: var(--fs-s);
  color: var(--text-muted);
  text-align: left;
  transition:
    color var(--dur-1) ease,
    background-color var(--dur-1) ease;
}

.lang__option:hover,
.lang__option:focus-visible {
  color: var(--text);
  background: var(--line);
  outline: none;
}

.lang__option[aria-current="true"] {
  color: var(--text);
}

.lang__option-code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.lang__option[aria-current="true"] .lang__option-code {
  color: var(--text);
}

/* -------------------------------------------------------------------------- */
/* Mobile menu                                                                */
/* -------------------------------------------------------------------------- */

.menu-toggle {
  display: none;
}

.menu-toggle__lines {
  position: relative;
  width: 16px;
  height: 10px;
}

.menu-toggle__lines span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transition:
    transform var(--dur-2) var(--ease-out),
    top var(--dur-2) var(--ease-out);
}

.menu-toggle__lines span:first-child {
  top: 1px;
}

.menu-toggle__lines span:last-child {
  top: 7.5px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__lines span:first-child {
  top: 4.25px;
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__lines span:last-child {
  top: 4.25px;
  transform: rotate(-45deg);
}

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  padding: calc(var(--topbar-h) + 48px) var(--gutter) max(48px, env(safe-area-inset-bottom));
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--dur-3) var(--ease-out),
    visibility 0s linear var(--dur-3);
}

.mobile-menu.is-open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.mobile-menu__list {
  display: grid;
  gap: 6px;
}

.mobile-menu__list a {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 9vw, 3rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: var(--tracking-tight);
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(16px);
  transition:
    color var(--dur-2) ease,
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out);
}

.mobile-menu.is-open .mobile-menu__list a {
  opacity: 1;
  transform: none;
}

.mobile-menu__list li:nth-child(2) a { transition-delay: 40ms; }
.mobile-menu__list li:nth-child(3) a { transition-delay: 80ms; }
.mobile-menu__list li:nth-child(4) a { transition-delay: 120ms; }
.mobile-menu__list li:nth-child(5) a { transition-delay: 160ms; }
.mobile-menu__list li:nth-child(6) a { transition-delay: 200ms; }

.mobile-menu__list a.is-active,
.mobile-menu__list a:hover {
  color: var(--text);
}

@media (max-width: 860px) {
  .nav {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
  }
}

/* -------------------------------------------------------------------------- */
/* Laptop mockup                                                              */
/* All inner sizes use cqw so the device scales as one piece.                 */
/* -------------------------------------------------------------------------- */

.device {
  container-type: inline-size;
  position: relative;
  width: 100%;
  isolation: isolate;
}

.device__lid {
  position: relative;
  width: 84%;
  margin-inline: auto;
  padding: 0.42cqw;
  border-radius: 2.1cqw 2.1cqw 0.5cqw 0.5cqw;
  background: var(--device-shell);
  box-shadow:
    inset 0 0 0 1px var(--device-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    var(--device-lift);
}

.device__bezel {
  position: relative;
  padding: 1.35cqw 1.3cqw 1.55cqw;
  border-radius: 1.75cqw 1.75cqw 0.35cqw 0.35cqw;
  background: #050506;
}

.device__camera {
  position: absolute;
  top: 0.45cqw;
  left: 50%;
  width: 0.5cqw;
  height: 0.5cqw;
  margin-left: -0.25cqw;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #313848 0%, #0a0b0f 70%);
}

.device__screen {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 0.45cqw;
  background: var(--screen-bg);
  isolation: isolate;
}

/* Soft glass reflection across the screen. */
.device__screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(118deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0) 36%);
}

.device__hinge {
  width: 76%;
  height: 0.55cqw;
  margin-inline: auto;
  border-radius: 0 0 0.6cqw 0.6cqw;
  background: linear-gradient(180deg, #050506 0%, var(--device-base-mid) 100%);
}

.device__base {
  position: relative;
  width: 100%;
  height: 1.7cqw;
  margin-top: -0.2cqw;
  border-radius: 0.3cqw 0.3cqw 3cqw 3cqw / 0.3cqw 0.3cqw 1.4cqw 1.4cqw;
  background: linear-gradient(
    180deg,
    var(--device-base-top) 0%,
    var(--device-base-mid) 38%,
    var(--device-base-bottom) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 1px rgba(0, 0, 0, 0.25);
}

/* Thumb notch to open the lid. */
.device__base::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 12%;
  height: 0.6cqw;
  transform: translateX(-50%);
  border-radius: 0 0 0.9cqw 0.9cqw;
  background: linear-gradient(180deg, var(--device-groove) 0%, var(--device-base-mid) 100%);
}

.device__shadow {
  position: absolute;
  z-index: -1;
  left: 6%;
  right: 6%;
  bottom: -2.4cqw;
  height: 4cqw;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--device-shadow), transparent);
  filter: blur(1.2cqw);
}

/* -------------------------------------------------------------------------- */
/* Miniature browser window (inside the screen)                               */
/* -------------------------------------------------------------------------- */

.browser {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--screen-bg);
}

.browser__bar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 3.1cqw;
  padding: 0 1.2cqw;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-line);
}

.browser__dots {
  display: flex;
  gap: 0.55cqw;
}

.browser__dots span {
  width: 0.7cqw;
  height: 0.7cqw;
  border-radius: 50%;
  background: var(--chrome-dot);
}

.browser__url {
  min-width: 24cqw;
  max-width: 40cqw;
  height: 1.85cqw;
  padding: 0 1.4cqw;
  overflow: hidden;
  border-radius: 0.55cqw;
  background: var(--chrome-url-bg);
  color: var(--chrome-text);
  font-size: 0.95cqw;
  font-weight: 500;
  line-height: 1.85cqw;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.browser__view {
  position: relative;
  flex: 1;
  overflow: hidden;
}

/* Screenshot. Tall captures scroll from top to bottom on hover. */
.shot {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--screen-bg);
}

.shot img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.shot.is-tall img {
  height: auto;
  transition:
    top var(--scroll-dur, 6s) var(--ease-in-out),
    transform var(--scroll-dur, 6s) var(--ease-in-out);
}

.is-scrollable:hover .shot.is-tall img,
.is-scrollable:focus-visible .shot.is-tall img {
  top: 100%;
  transform: translateY(-100%);
}

.shot.is-broken img {
  display: none;
}

/* Slideshow (hero): screenshots cross-fade. */
.slides {
  position: absolute;
  inset: 0;
}

.slides .shot {
  opacity: 0;
  transition: opacity 1200ms var(--ease-in-out);
}

.slides .shot.is-active {
  opacity: 1;
}

/* Terminal (projects without a screenshot). Always dark, like a real terminal. */
.term {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(70% 60% at 100% 0%, rgba(var(--glow-rgb), 0.08), transparent 70%),
    #0a0b0e;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-mono);
}

.term__bar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 3.1cqw;
  padding: 0 1.2cqw;
  background: #15161a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.term__bar .browser__dots span {
  background: #34353c;
}

.term__name {
  font-size: 0.95cqw;
  color: rgba(255, 255, 255, 0.45);
}

.term__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5cqw;
  padding: 2.6cqw 3cqw;
  overflow: hidden;
  font-size: 1.65cqw;
  line-height: 1.6;
}

.term__prompt {
  color: var(--status);
}

.term__title {
  margin-top: 1cqw;
  font-family: var(--font-mono);
  font-size: 2.6cqw;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
}

.term__meta {
  color: rgba(255, 255, 255, 0.4);
}

.term__text {
  display: -webkit-box;
  white-space: pre-line;
  margin-bottom: 1cqw;
  overflow: hidden;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
}

.term__cursor {
  display: inline-block;
  width: 0.75cqw;
  height: 1.5cqw;
  vertical-align: -0.2cqw;
  background: rgba(255, 255, 255, 0.75);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Wireframe placeholder shown while a project has no screenshot. */
.wire {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 2.2cqw;
  padding: 2.4cqw 4cqw;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(var(--glow-rgb), 0.08), transparent 70%),
    var(--screen-bg);
}

.wire__nav,
.wire__hero,
.wire__cards {
  display: flex;
  gap: 1.2cqw;
}

.wire__nav {
  justify-content: space-between;
  align-items: center;
}

.wire__hero {
  flex-direction: column;
  align-items: center;
  gap: 1.1cqw;
  padding-top: 3cqw;
}

.wire__cards > i {
  flex: 1;
  height: 100%;
  min-height: 8cqw;
  border-radius: 0.8cqw;
}

.wire i {
  display: block;
  border-radius: 0.4cqw;
  background: var(--screen-skeleton);
}

/* Hero wallpaper shown when there is no screenshot yet. */
.wallpaper {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(55% 75% at 18% 12%, rgba(var(--glow-rgb), 0.42), transparent 62%),
    radial-gradient(45% 65% at 88% 92%, rgba(255, 150, 110, 0.2), transparent 62%),
    radial-gradient(40% 50% at 70% 20%, rgba(90, 200, 220, 0.12), transparent 60%),
    linear-gradient(160deg, #11111a 0%, #07070a 100%);
}

.wallpaper__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 2.5cqw;
  padding: 0 1.6cqw;
  background: rgba(0, 0, 0, 0.22);
  -webkit-backdrop-filter: blur(1cqw);
  backdrop-filter: blur(1cqw);
  font-size: 0.95cqw;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
}

.wallpaper__bar-left {
  display: flex;
  align-items: center;
  gap: 1.4cqw;
}

.wallpaper__bar-left i {
  width: 0.8cqw;
  height: 0.8cqw;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
}

.wallpaper__center {
  display: grid;
  justify-items: center;
  gap: 1.3cqw;
  text-align: center;
}

.wallpaper__name {
  font-family: var(--font-display);
  font-size: 6.4cqw;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.05em;
}

.wallpaper__role {
  font-family: var(--font-mono);
  font-size: 1.05cqw;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.wallpaper__dock {
  position: absolute;
  bottom: 1.4cqw;
  left: 50%;
  display: flex;
  gap: 0.9cqw;
  padding: 0.8cqw;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.4cqw;
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(1cqw);
  backdrop-filter: blur(1cqw);
}

.wallpaper__dock i {
  width: 3cqw;
  height: 3cqw;
  border-radius: 0.8cqw;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08));
}

/* -------------------------------------------------------------------------- */
/* Tags                                                                       */
/* -------------------------------------------------------------------------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  transition:
    color var(--dur-2) ease,
    border-color var(--dur-2) ease;
}

.tag--s {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

.tag:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.tag.is-pending {
  width: var(--w, 72px);
  border-color: transparent;
  background: var(--skeleton);
}

/* -------------------------------------------------------------------------- */
/* Lightbox (enlarged project screen)                                         */
/* -------------------------------------------------------------------------- */

:root.has-dialog {
  overflow: hidden;
}

.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: lightbox-in 420ms var(--ease-out);
}

.lightbox::backdrop {
  background: rgba(6, 6, 8, 0.78);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

:root[data-theme="light"] .lightbox::backdrop {
  background: rgba(236, 236, 232, 0.82);
}

.lightbox__inner {
  display: grid;
  justify-items: center;
  gap: 24px;
  width: min(1080px, 100% - 2 * var(--gutter), 150vh);
  padding-block: 80px 48px;
}

.lightbox__stage {
  width: 100%;
}

.lightbox__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.lightbox__close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text);
}

.lightbox__close svg {
  width: 18px;
  height: 18px;
}

/* The full README is shown, no line clamp. */
.lightbox .term__text {
  display: block;
  -webkit-line-clamp: unset;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

/* On phones a laptop is too small to read: show the terminal as a plain window. */
@media (max-width: 760px) {
  .lightbox__inner {
    width: calc(100% - 24px);
  }

  .lightbox .device:has(.term) .device__lid {
    width: 100%;
    padding: 0;
    background: none;
    box-shadow: none;
  }

  .lightbox .device:has(.term) .device__bezel {
    padding: 0;
    background: none;
  }

  .lightbox .device:has(.term) :is(.device__camera, .device__hinge, .device__base, .device__shadow) {
    display: none;
  }

  .lightbox .device:has(.term) .device__screen {
    aspect-ratio: auto;
    border-radius: 14px;
    box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.7);
  }

  .lightbox .device:has(.term) .device__screen::after {
    display: none;
  }

  .lightbox .term {
    position: relative;
    inset: auto;
  }

  .lightbox .term__bar {
    height: 36px;
    padding: 0 14px;
  }

  .lightbox .term__bar .browser__dots {
    gap: 6px;
  }

  .lightbox .term__bar .browser__dots span {
    width: 9px;
    height: 9px;
  }

  .lightbox .term__name {
    font-size: 12px;
  }

  .lightbox .term__body {
    gap: 6px;
    padding: 20px 18px 24px;
    font-size: 13px;
  }

  .lightbox .term__title {
    margin-top: 8px;
    font-size: 22px;
  }

  .lightbox .term__cursor {
    width: 8px;
    height: 16px;
    vertical-align: -3px;
  }
}
