:root {
  --gd-bg: #3e4637;
  --gd-panel: #4c5844;
  --gd-panel-alt: #5a6a50;
  --gd-border-hi: #899281;
  --gd-border-lo: #292d23;
  --gd-text: #d8ded3;
  --gd-text-dim: #b8c4ad;
  --gd-accent: #c4b550;
  --gd-link: #b8a040;
  --font-copy: system-ui, "Segoe UI", Arial, sans-serif;
  --font-ui: "Trebuchet MS", Verdana, sans-serif;
  --font-code: Consolas, "Courier New", monospace;
}

html {
  scrollbar-gutter: stable both-edges;
}

body {
  position: relative;
  min-height: 100vh;
  font-family: var(--font-copy);
  line-height: 1.46;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

p {
  line-height: 1.46;
}

code {
  font-family: var(--font-code);
  font-size: 0.92em;
}

.topbar,
.window:not(.headless)::before,
.titlebar,
.button-link,
.project-tagline,
.project-stack,
.project-placeholder,
.projects-more summary,
.projects-more__count,
.marquee-track span {
  font-family: var(--font-ui);
}

#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.45;
}

.portfolio-shell {
  position: relative;
  z-index: 1;
  max-width: 1020px;
  margin: 0 auto;
  gap: 0;
}

.topbar {
  z-index: 20;
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  overflow: hidden;
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  background: var(--gd-panel);
  margin-bottom: 20px;
  max-width: none;
}

.topbar__group {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  min-width: 0;
}

.topbar__links {
  flex: 1 1 auto;
}

.topbar__actions {
  flex: 0 0 auto;
  margin-left: auto;
  border-left: solid 1px var(--gd-border-hi);
}

.topbar__link,
.topbar__icon-link,
.topbar__icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  min-width: auto;
  color: var(--gd-accent);
  background: transparent;
  border: 0;
  border-left: solid 1px var(--gd-border-hi);
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
}

.topbar__links > :first-child,
.topbar__actions > :first-child {
  border-left: 0;
}

.topbar__link {
  padding: 0 26px;
  justify-content: flex-start;
}

.topbar__link--home {
  min-width: 56px;
  justify-content: center;
}

.topbar__icon-link,
.topbar__icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  flex: 0 0 44px;
}

.topbar__link:hover,
.topbar__link:focus-visible,
.topbar__icon-link:hover,
.topbar__icon-link:focus-visible,
.topbar__icon-button:hover,
.topbar__icon-button:focus-visible {
  color: #e3e41f;
  background: var(--gd-panel-alt);
  text-decoration: none;
}

.topbar__icon-button:focus-visible,
.topbar__icon-link:focus-visible,
.topbar__link:focus-visible {
  outline: 1px dashed var(--gd-border-lo);
  outline-offset: -4px;
}

.topbar__icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body[data-theme="black"] .topbar__link:hover,
body[data-theme="black"] .topbar__icon-link:hover,
body[data-theme="black"] .topbar__icon-button:hover {
  color: #f0b43f;
}


.window {
  max-width: 1020px;
}

.window-row {
  max-width: 1020px;
}

.hero-window {
  padding-top: 12px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
}

.hero-avatar {
  min-height: 230px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  margin: 0;
  image-rendering: auto;
}

.hero-copy h1 {
  margin: 0 12px 4px;
  font-size: clamp(27px, 4vw, 41px);
  line-height: 1.02;
}

.hero-copy p {
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.5;
}

.hero-role {
  margin: 0 12px;
  color: var(--gd-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
}

.hero-divider {
  height: 1px;
  margin: 10px 12px;
  background: var(--gd-border-hi);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 12px 0;
}

.button-link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 14px;
  color: #fff;
  text-decoration: none;
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  background: var(--gd-panel);
}

.button-link:active {
  border-top: solid 1px var(--gd-border-lo);
  border-bottom: solid 1px var(--gd-border-hi);
  border-left: solid 1px var(--gd-border-lo);
  border-right: solid 1px var(--gd-border-hi);
}

.marquee-shell .titlebar {
  margin-bottom: 8px;
}

.marquee-wrap {
  overflow: hidden;
  padding: 10px 0;
}

.marquee-track {
  display: flex;
  width: max-content;
  gap: 28px;
  padding-inline: 16px;
  will-change: transform;
}

.marquee-track span {
  color: var(--gd-accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 12px 12px;
}

.projects-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  width: 100%;
}

#projects.window {
  max-width: 1020px;
  width: 100%;
}

/* Two-zone card: header band on top, body (text + preview) below */

.project-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  padding: 0;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.project-card:hover {
  transform: translateY(-2px);
}

.project-card-header {
  background: var(--gd-panel-alt);
  padding: 10px 12px 8px;
  border-bottom: solid 1px var(--gd-border-lo);
}

.project-card-header .project-title {
  margin: 0;
  font-weight: 700;
  color: #fff;
  font-size: 17px;
  line-height: 1.22;
}

.project-card-header .project-tagline {
  margin: 4px 0 0;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  color: var(--gd-text-dim);
}

.project-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 42%);
  gap: 12px;
  padding: 12px;
  flex: 1;
  align-items: stretch;
}

.project-info {
  min-width: 0;
}

.project-card-body .project-info > p:not(.project-stack) {
  margin: 0 0 8px;
  max-width: 76ch;
  font-size: 13px;
  line-height: 1.45;
}

.project-card-body .project-info > p:not(.project-stack):last-of-type {
  margin-bottom: 0;
}

.project-card-body .project-stack {
  margin-top: 10px;
  color: var(--gd-accent);
  font-size: 11.5px;
  line-height: 1.35;
}

.project-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  background: var(--gd-panel-alt);
  overflow: hidden;
  transition: background 0.2s;
}

.project-preview:hover {
  background: var(--gd-panel);
}

.project-card-body .project-preview {
  align-self: stretch;
}

.project-preview.has-image {
  padding: 0;
  position: relative;
}

.project-preview.has-image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  object-fit: cover;
  object-position: center;
  background: var(--gd-bg);
}

.project-placeholder {
  color: var(--gd-text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.projects-more {
  margin-top: 10px;
  margin-bottom: 0;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.projects-more summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 28px;
  padding: 4px 8px;
  margin: -10px -10px 10px;
  color: #fff;
  background: var(--gd-panel-alt);
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  cursor: pointer;
  list-style: none;
}

.projects-more summary::-webkit-details-marker {
  display: none;
}

.projects-more summary::before {
  content: "+";
  flex: 0 0 auto;
  width: 14px;
  color: var(--gd-accent);
}

.projects-more[open] summary::before {
  content: "-";
}

.projects-more:not([open]) summary {
  margin-bottom: -10px;
}

.projects-more summary span:first-of-type {
  margin-right: auto;
}

.projects-more__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  color: var(--gd-accent);
  background: var(--gd-panel);
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  box-sizing: border-box;
  font-size: 11px;
}

.projects-grid-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.project-card-compact {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  padding: 10px;
  background: transparent;
  border-top: solid 1px rgba(255, 255, 255, 0.12);
  border-bottom: 0;
  border-left: 0;
  border-right: 0;
  box-sizing: border-box;
}

.project-card-compact:nth-child(-n + 2) {
  border-top: 0;
}

.project-card-compact p {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.38;
}

.project-card-compact .project-title {
  margin: 0 0 3px;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
}

.project-card-compact .project-tagline {
  margin: 0 0 7px;
  color: var(--gd-text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.project-card-compact .project-stack {
  margin-top: 8px;
  color: var(--gd-accent);
  font-size: 12px;
  line-height: 1.3;
}

.project-compact-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-compact-info .project-link {
  align-self: flex-start;
  margin-top: auto;
  color: var(--gd-link);
}

.project-mini-preview {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 126px;
  padding: 10px;
  color: var(--gd-accent);
  text-decoration: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    var(--gd-panel-alt);
  background-size: 12px 12px;
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  box-sizing: border-box;
  overflow: hidden;
}

.project-mini-preview:hover,
.project-mini-preview:focus-visible {
  background-color: var(--gd-panel);
}

.project-mini-preview span {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: inherit;
  font-family: var(--font-code);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-mini-preview span:first-child {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.project-mini-preview.has-image {
  padding: 0;
  background: var(--gd-panel-alt);
}

.project-mini-preview.has-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 126px;
  margin: 0;
  border: 0;
  object-fit: cover;
  object-position: center;
}

.project-mini-preview--tag::after,
.project-mini-preview--practice::after,
.project-mini-preview--ocr::after,
.project-mini-preview--clock::after,
.project-mini-preview--imax::after {
  content: "";
  position: absolute;
  inset: auto 10px 10px auto;
  width: 36px;
  height: 36px;
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  background: rgba(0, 0, 0, 0.16);
}

.timeline {
  margin: 0;
  padding: 0 12px 0 28px;
}

.timeline li {
  margin-bottom: 14px;
}

.timeline-head {
  margin: 0 0 4px;
  color: #fff;
}

.skills-grid {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.skills-grid span {
  border-top: solid 1px var(--gd-border-hi);
  border-bottom: solid 1px var(--gd-border-lo);
  border-left: solid 1px var(--gd-border-hi);
  border-right: solid 1px var(--gd-border-lo);
  background: var(--gd-panel);
  padding: 8px;
  color: var(--gd-text);
  font-size: 12px;
}

.contact-actions {
  margin: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#restore-hero {
  color: var(--gd-accent);
}

.taiko-game {
  text-align: center;
  padding: 4px 0 0;
}

.taiko-hint {
  margin: 6px 0 4px;
  font-size: 12px;
  color: var(--gd-text-dim);
  letter-spacing: 0.5px;
}

.taiko-canvas {
  display: block;
  width: 100%;
  height: 100px;
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
}

.taiko-key {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.taiko-red {
  background: #c0392b;
  color: #fff;
}

.taiko-blue {
  background: #2980b9;
  color: #fff;
}

.taiko-status {
  margin: 4px 0 6px;
  font-size: 13px;
  color: var(--gd-text);
  letter-spacing: 0.5px;
  min-height: 18px;
}

.char {
  display: inline-block;
  will-change: transform, opacity;
}

.reveal {
  opacity: 1;
}

body.has-js .reveal {
  opacity: 0;
}

.topbar a.active-link {
  color: #e3e41f;
  background: var(--gd-panel-alt);
}

body[data-theme="black"] .topbar a.active-link {
  color: #f0b43f;
}

body[data-theme="green"] {
  background: var(--gd-bg);
}

body[data-theme="black"] {
  --gd-bg: #080808;
  --gd-panel: #212121;
  --gd-panel-alt: #181818;
  --gd-border-hi: #323232;
  --gd-border-lo: #080808;
  --gd-accent: #F0B43F;
  --gd-link: #F0B43F;
  --gd-text-dim: #b8c4ad;
  background: #080808;
}

body[data-theme="black"] .theme-toggle__icon {
  color: #f0b43f;
}

body[data-theme="green"] .theme-toggle__icon {
  color: #c4b550;
}

body[data-theme="moonlight"] {
  --gd-bg: #10171a;
  --gd-panel: rgba(24, 33, 36, 0.88);
  --gd-panel-alt: rgba(36, 48, 52, 0.9);
  --gd-border-hi: #71808a;
  --gd-border-lo: #071013;
  --gd-text: #d6d2c2;
  --gd-text-dim: #a8b0ad;
  --gd-accent: #d0b46f;
  --gd-link: #dfc47d;
  color: var(--gd-text);
  background: #10171a;
}

body[data-theme="moonlight"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(12, 18, 21, 0.35), rgba(12, 18, 21, 0.82)),
    url("../assets/dresden-moonlight-preview.gif") center top / cover no-repeat,
    #10171a;
  transform: translateZ(0);
}

body[data-theme="moonlight"] #bgCanvas {
  opacity: 0.1;
  mix-blend-mode: normal;
}

body[data-theme="moonlight"] .topbar,
body[data-theme="moonlight"] .window,
body[data-theme="moonlight"] .box {
  background-color: var(--gd-panel);
  border-top-color: var(--gd-border-hi);
  border-bottom-color: var(--gd-border-lo);
  border-left-color: var(--gd-border-hi);
  border-right-color: var(--gd-border-lo);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: none;
}

body[data-theme="moonlight"] .topbar__link,
body[data-theme="moonlight"] .topbar__icon-link,
body[data-theme="moonlight"] .topbar__icon-button {
  color: var(--gd-accent);
  border-left-color: rgba(113, 128, 138, 0.58);
}

body[data-theme="moonlight"] .topbar__link:hover,
body[data-theme="moonlight"] .topbar__link:focus-visible,
body[data-theme="moonlight"] .topbar__icon-link:hover,
body[data-theme="moonlight"] .topbar__icon-link:focus-visible,
body[data-theme="moonlight"] .topbar__icon-button:hover,
body[data-theme="moonlight"] .topbar__icon-button:focus-visible,
body[data-theme="moonlight"] nav a.active-link {
  color: #f0dfaa;
  background: rgba(61, 80, 87, 0.82);
}

body[data-theme="moonlight"] .hero-copy h1 .char,
body[data-theme="moonlight"] .hero-role,
body[data-theme="moonlight"] .project-card .project-title,
body[data-theme="moonlight"] .project-card-compact .project-title,
body[data-theme="moonlight"] .timeline-head {
  color: #f0ead6;
}

body[data-theme="moonlight"] .button-link,
body[data-theme="moonlight"] .projects-more__count {
  color: #f0dfaa;
  background: rgba(17, 25, 28, 0.88);
  border-top-color: var(--gd-border-hi);
  border-bottom-color: var(--gd-border-lo);
  border-left-color: var(--gd-border-hi);
  border-right-color: var(--gd-border-lo);
}

body[data-theme="moonlight"] .button-link:hover {
  color: #10171a;
  background: #d0b46f;
}

body[data-theme="moonlight"] .project-preview,
body[data-theme="moonlight"] .project-mini-preview,
body[data-theme="moonlight"] .skills-grid span,
body[data-theme="moonlight"] .projects-more summary {
  background-color: var(--gd-panel-alt);
  border-top-color: rgba(139, 154, 162, 0.9);
  border-bottom-color: rgba(5, 10, 12, 0.95);
  border-left-color: rgba(139, 154, 162, 0.9);
  border-right-color: rgba(5, 10, 12, 0.95);
}

body[data-theme="moonlight"] .project-card-compact {
  background: rgba(8, 15, 18, 0.36);
  border-top-color: rgba(139, 154, 162, 0.24);
  box-shadow: none;
  backdrop-filter: none;
}

body[data-theme="moonlight"] .project-mini-preview {
  background:
    linear-gradient(90deg, rgba(214, 210, 194, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(214, 210, 194, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 74% 20%, rgba(223, 196, 125, 0.22), transparent 28%),
    rgba(36, 48, 52, 0.9);
  background-size: 12px 12px, 12px 12px, auto, auto;
}

body[data-theme="moonlight"] .hero-avatar img {
  filter: saturate(0.78) contrast(1.08);
}

body[data-theme="moonlight"] .marquee-track span,
body[data-theme="moonlight"] .project-card .project-stack,
body[data-theme="moonlight"] .project-card-compact .project-stack,
body[data-theme="moonlight"] .project-mini-preview,
body[data-theme="moonlight"] .project-link {
  color: var(--gd-accent);
}

body[data-theme="moonlight"] .window::before,
body[data-theme="moonlight"] .titlebar,
body[data-theme="moonlight"] legend,
body[data-theme="moonlight"] .projects-more summary {
  color: #f0ead6;
}

@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .window-row {
    flex-direction: column;
  }

  .window.half,
  .window-row .window {
    max-width: 100%;
  }

  .projects-list {
    grid-template-columns: 1fr;
  }

  .project-card-body {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 40%);
  }

  .project-preview {
    width: 100%;
    min-height: 140px;
  }

  .projects-grid-compact {
    grid-template-columns: 1fr;
  }

  .project-card-compact {
    grid-template-columns: 132px minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .project-card-body {
    grid-template-columns: 1fr;
  }

  .project-card-compact {
    grid-template-columns: 1fr;
  }

  .project-mini-preview,
  .project-mini-preview.has-image img {
    min-height: 150px;
  }
}

/* ---- Clickable preview trigger ---- */

.project-preview.preview-modal-trigger {
  cursor: zoom-in;
  /* reset button defaults so it still looks like the original .project-preview */
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
}

/* ---- Lightbox modal ---- */

.media-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 50vw;   
  max-height: 50vh;  
  overflow: visible;
}

.media-modal::backdrop {
  background: rgba(0, 0, 0, 0.88);
}

.media-modal img {
  display: block;
  max-width: 50vw;    
  max-height: 45vh;  
  width: auto;
  height: auto;
  object-fit: contain;
  border-top: 1px solid var(--gd-border-hi);
  border-left: 1px solid var(--gd-border-hi);
  border-bottom: 1px solid var(--gd-border-lo);
  border-right: 1px solid var(--gd-border-lo);
}

.media-modal-close {
  position: absolute;
  top: -38px;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 0;
  padding: 0;
  background: var(--gd-panel);
  color: var(--gd-text);
  border-top: 1px solid var(--gd-border-hi);
  border-left: 1px solid var(--gd-border-hi);
  border-bottom: 1px solid var(--gd-border-lo);
  border-right: 1px solid var(--gd-border-lo);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
  box-sizing: border-box;
}

.media-modal-close:hover {
  background: var(--gd-panel-alt);
  color: var(--gd-accent);
}

@media (max-width: 768px) {
  .media-modal,
  .media-modal img {
    max-width: 92vw;
    max-height: 70vh;
  }
}
