/* ============================================================
   CUBE — Index
   Monochrome. Light = 255 white, Dark = 0 black.
   ============================================================ */

:root {
  --bg:    #ffffff;
  --ink:   #000000;
  --line:  rgba(0, 0, 0, .14);
  --muted: rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .82);
  --logo-invert: 0;

  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, "Menlo", monospace;
  --sans: "Inter", "Helvetica Neue", "Arial", system-ui, sans-serif;

  --gap: clamp(8px, 1.2vw, 18px);
  --pad: clamp(16px, 4vw, 56px);
}

:root[data-theme="dark"] {
  --bg:    #000000;
  --ink:   #ffffff;
  --line:  rgba(255, 255, 255, .16);
  --muted: rgba(255, 255, 255, .55);
  --scrim: rgba(0, 0, 0, .85);
  --logo-invert: 1;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* ---------- Seamless page transitions (Swup) ---------- */
/* Only <main> (#swup) swaps; header/footer persist, so there is no
   chrome flicker. The content cross-fades via this class. */
.transition-fade { transition: opacity .26s ease; opacity: 1; }
html.is-animating .transition-fade { opacity: 0; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; }
.brand img {
  height: 34px; width: auto; display: block;
  filter: invert(var(--logo-invert));
}

.header-right { display: flex; align-items: center; gap: 16px; }

.site-nav { display: flex; gap: 20px; }
.nav-link {
  position: relative;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 4px 0;
  transition: color .2s;
}
.nav-link:hover { color: var(--ink); }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1px; background: var(--ink);
}

.theme-toggle {
  width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center; color: var(--ink); font-size: 16px;
  transition: background .2s, color .2s, border-color .2s;
}
.theme-toggle:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.theme-toggle .bi { line-height: 1; }
/* show moon in light mode, sun in dark mode */
.theme-toggle .bi-sun-fill { display: none; }
.theme-toggle .bi-moon-stars-fill { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .bi-sun-fill { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }

/* ---------- Archive grid ---------- */
main { padding: var(--pad); padding-top: 28px; min-height: 64vh; }

.archive {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}
@media (max-width: 1100px) { .archive { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .archive { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px)  { .archive { grid-template-columns: 1fr; } }

.card {
  position: relative; display: block; width: 100%;
  text-align: left; color: inherit;
  opacity: 0; transform: translateY(8px);
  animation: rise .5s ease forwards;
}
@keyframes rise { to { opacity: 1; transform: none; } }

.card-thumb {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--line);
  border: 1px solid transparent;
  transition: border-color .25s;
}
.card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.card:hover .card-thumb img { transform: scale(1.05); }
.card:hover .card-thumb { border-color: var(--ink); }

/* title overlay — visible on hover only */
.card-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: flex-end;
  padding: 12px;
  background: linear-gradient(to top, var(--scrim) 0%, transparent 60%);
  opacity: 0; transition: opacity .25s ease;
  pointer-events: none;
}
.card:hover .card-overlay,
.card:focus-visible .card-overlay { opacity: 1; }
.card-title {
  color: #fff; font-size: 13px; line-height: 1.32; letter-spacing: -.003em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-note { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: center; padding: 40px; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 18px var(--pad); border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
.footer-row { display: flex; justify-content: space-between; gap: 12px; }
.to-top:hover { color: var(--ink); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 4vw; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.86); backdrop-filter: blur(4px); }
.lb-inner {
  position: relative; width: min(1000px, 100%);
  background: var(--bg); border: 1px solid var(--ink);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  animation: pop .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.lb-bar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.lb-index { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.lb-title { flex: 1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-close { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.lb-close:hover { opacity: .6; }
.lb-frame { aspect-ratio: 16/9; background: #000; }
.lb-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.lb-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.lb-link:hover { opacity: .6; }
.lb-nav { display: flex; gap: 14px; }
.lb-nav button:hover { opacity: .6; }

/* ---------- Sub pages (About / Contact / 404) ---------- */
.page { padding: var(--pad); padding-top: clamp(40px, 8vh, 90px); min-height: 64vh; }
.page-title {
  font-size: clamp(28px, 5vw, 44px); letter-spacing: -.02em;
  font-weight: 600; margin: 0 0 16px;
}

/* About */
.about { display: flex; align-items: center; justify-content: center; }
.about-inner { max-width: 600px; width: 100%; text-align: center; padding: 2vh 0 6vh; }
.about-logo img {
  width: 104px; height: auto; margin: 0 auto 30px; display: block;
  filter: invert(var(--logo-invert));
}
.bio { font-size: 15px; line-height: 1.95; margin: 0 0 44px; }

.profile { max-width: 460px; margin: 0 auto 44px; text-align: left; }
.profile-item {
  display: grid; grid-template-columns: 96px 1fr; gap: 18px;
  padding: 13px 2px; border-top: 1px solid var(--line);
}
.profile-item:last-child { border-bottom: 1px solid var(--line); }
.profile-item dt {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.profile-item dd { margin: 0; font-size: 13.5px; line-height: 1.5; }

.social-links { display: flex; gap: 16px; justify-content: center; }
.social-link {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center; color: var(--ink);
  transition: background .2s, color .2s, border-color .2s;
}
.social-link:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.social-link svg { width: 17px; height: 17px; fill: currentColor; display: block; }

/* Contact */
.contact-inner { max-width: 560px; margin: 0 auto; }
.contact-description { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 0 0 38px; }
.contact-form[hidden] { display: none; }
.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.form-group label {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.form-group input,
.form-group textarea {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  padding: 12px 14px; font: inherit; font-size: 14px; border-radius: 0;
  transition: border-color .2s;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--ink); }
.form-group textarea { resize: vertical; min-height: 120px; }
.submit-btn {
  background: var(--ink); color: var(--bg); padding: 13px 30px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em;
  text-transform: uppercase; transition: opacity .2s;
}
.submit-btn:hover { opacity: .82; }
.submit-btn:disabled { opacity: .5; cursor: default; }
.form-status { font-size: 13px; margin: 16px 0 0; }
.form-status.is-error { color: #e0533a; }

.contact-success { text-align: center; padding: 5vh 0; }
.contact-success h2 { font-size: 22px; margin: 0 0 16px; font-weight: 600; }
.contact-success p { color: var(--muted); line-height: 1.85; margin: 0; }

/* 404 */
.notfound { display: flex; align-items: center; justify-content: center; text-align: center; }
.notfound-inner { max-width: 520px; }
.nf-code { font-family: var(--mono); font-size: 13px; letter-spacing: .24em; color: var(--muted); margin: 0 0 20px; }
.nf-desc { color: var(--muted); font-size: 14px; line-height: 1.85; margin: 14px 0 34px; }
.nf-back {
  display: inline-block; border: 1px solid var(--ink); padding: 12px 28px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; transition: background .2s, color .2s;
}
.nf-back:hover { background: var(--ink); color: var(--bg); }

@media (max-width: 600px) {
  .site-nav { gap: 14px; }
  .nav-link { font-size: 11px; }
  .header-right { gap: 12px; }
  .theme-toggle { width: 34px; height: 34px; font-size: 15px; }
}

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