/* =============================================================================
   SHARED STYLES — design tokens, themes, and components.
   Aesthetic: Nintendo 3DS home menu × Frutiger Aero × glossy skeuomorphism.
   Light = silvery-grey interface / white boxes / blue highlights.
   Dark  = dark-grey version, same blue accent.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&display=swap");

/* ----------------------------------------------------------------------------
   1. DESIGN TOKENS + THEMES  (data-theme on <html>: "light" | "dark")
---------------------------------------------------------------------------- */
:root {
  /* Typography — one humanist/techy family throughout */
  --font-head: "Titillium Web", "Segoe UI", system-ui, sans-serif;
  --font-body: "Titillium Web", "Segoe UI", system-ui, sans-serif;

  /* Shape — crisp, interface-like (not bubbly) */
  --radius-sm: 4px;
  --radius-md: 8px;   /* tiles / cards / icons */
  --radius-lg: 10px;  /* panels / frames */
  --radius-pill: 999px;

  /* Motion */
  --ease-pop: cubic-bezier(0.2, 0.8, 0.3, 1);

  /* ---- Theme: LIGHT (3DS homescreen) — default ---- */
  --bg-1: #eef0f3;
  --bg-2: #d8dce1;
  --bg-3: #c6cbd2;

  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --line: #c6ccd4;             /* skeuomorphic 1px borders */
  --line-soft: #dfe3e8;

  --ink: #333941;
  --ink-soft: #6b727c;

  --accent: #2b8fd6;           /* 3DS blue */
  --accent-top: #57a9e6;       /* gloss gradient top */
  --accent-bot: #1f7ec9;       /* gloss gradient bottom */
  --accent-line: #1a6cae;
  --accent-ink: #ffffff;
  --ring: #2b8fd6;

  --tile-top: #ffffff;
  --tile-bottom: #eef1f4;

  --chrome-top: #fbfcfd;       /* status bar gloss */
  --chrome-bot: #e6e9ee;
  --chrome-ink: #333941;

  --recess: #cfd4da;           /* inset "screen" frame background */
  --recess-2: #d9dde2;

  --gloss: rgba(255, 255, 255, 0.6);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.16), 0 8px 20px rgba(0, 0, 0, 0.14);
  --shadow-screen: 0 12px 34px rgba(0, 0, 0, 0.22);
  --inset: inset 0 2px 5px rgba(0, 0, 0, 0.22), inset 0 -1px 0 rgba(255, 255, 255, 0.25);
}

html[data-theme="dark"] {
  --bg-1: #33373f;
  --bg-2: #24272d;
  --bg-3: #191b1f;

  --surface: #2c3037;
  --surface-2: #363b43;
  --line: #454b55;
  --line-soft: #3a3f47;

  --ink: #eef1f5;
  --ink-soft: #a7adb8;

  --accent: #3f9fe0;
  --accent-top: #5cb0ea;
  --accent-bot: #2b8ad2;
  --accent-line: #1f6fb0;
  --accent-ink: #ffffff;
  --ring: #4aa6e6;

  --tile-top: #333840;
  --tile-bottom: #2a2e35;

  --chrome-top: #333840;
  --chrome-bot: #23262c;
  --chrome-ink: #eef1f5;

  --recess: #1c1e23;
  --recess-2: #212429;

  --gloss: rgba(255, 255, 255, 0.10);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-card-hover: 0 2px 5px rgba(0, 0, 0, 0.5), 0 10px 24px rgba(0, 0, 0, 0.55);
  --shadow-screen: 0 12px 34px rgba(0, 0, 0, 0.55);
  --inset: inset 0 2px 6px rgba(0, 0, 0, 0.55), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

/* ----------------------------------------------------------------------------
   2. BASE
---------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}

/* subtle Frutiger-Aero light bloom over the grey */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 70% at 50% -20%, rgba(255, 255, 255, 0.45), transparent 60%);
  z-index: 0;
}
html[data-theme="dark"] body::before {
  background: radial-gradient(120% 70% at 50% -20%, rgba(255, 255, 255, 0.06), transparent 60%);
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; margin: 0 0 0.4em; }
a { color: inherit; }

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

/* ----------------------------------------------------------------------------
   3. NAVBAR — 3DS-style glossy top bar
   Three zones: left (home tile + tabs) / center (clock) / right (controls)
---------------------------------------------------------------------------- */
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--chrome-ink);
  background: linear-gradient(180deg, var(--chrome-top), var(--chrome-bot));
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 3px rgba(0, 0, 0, 0.12);
}
.nav__zone { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav__zone--left { justify-self: start; }
.nav__zone--center { justify-self: center; }
.nav__zone--right { justify-self: end; }

.nav__home {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  font-size: 1.2rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom));
  box-shadow: inset 0 1px 0 var(--gloss), var(--shadow-card);
  transition: transform 0.12s var(--ease-pop), filter 0.15s ease;
}
.nav__home:hover { filter: brightness(1.05); transform: translateY(-1px); }
.nav__home:active { transform: translateY(1px); box-shadow: var(--inset); }
.nav__home[aria-current="page"] { border-color: var(--accent); box-shadow: inset 0 1px 0 var(--gloss), 0 0 0 2px var(--ring); }

.nav__tabs { display: flex; align-items: center; gap: 6px; overflow-x: auto; }
.nav__tab {
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--chrome-ink);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav__tab:hover { background: var(--surface); border-color: var(--line); }
.nav__tab[aria-current="page"] {
  color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-top), var(--accent-bot));
  border-color: var(--accent-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.nav .statusbar__clock,
.statusbar__clock { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; font-weight: 700; }
.nav .statusbar__date,
.statusbar__date { opacity: 0.75; font-size: 0.85em; }

.statusbar__btn {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: inherit;
  font: inherit;
  font-size: 1.05em;
  cursor: pointer;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  line-height: 1;
  box-shadow: inset 0 1px 0 var(--gloss);
  transition: transform 0.12s var(--ease-pop), filter 0.15s ease;
}
.statusbar__btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
.statusbar__btn:active { transform: translateY(1px); box-shadow: var(--inset); }

/* Responsive: tabs get the full top row; clock + controls share the second row
   (controls drop to the clock's level so they don't crowd the tabs). */
@media (max-width: 720px) {
  .nav {
    grid-template-columns: 1fr auto;
    grid-template-areas: "left left" "center right";
    row-gap: 8px;
  }
  .nav__zone--left { grid-area: left; }
  .nav__zone--center { grid-area: center; justify-self: start; }
  .nav__zone--right { grid-area: right; justify-self: end; }
  /* icon-only, compact theme toggle on mobile */
  .theme-toggle__label { display: none; }
  .theme-toggle { padding: 5px 8px; }
}
@media (max-width: 380px) {
  .nav .statusbar__date { display: none; }
}

/* ----------------------------------------------------------------------------
   4. THEME TOGGLE (single light/dark button)
---------------------------------------------------------------------------- */
.theme-toggle {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--chrome-ink);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: inset 0 1px 0 var(--gloss);
  transition: transform 0.12s var(--ease-pop), filter 0.15s ease;
}
.theme-toggle:hover { filter: brightness(1.04); transform: translateY(-1px); }
.theme-toggle:active { transform: translateY(1px); box-shadow: var(--inset); }

/* ----------------------------------------------------------------------------
   5. APP CARD (icon tile) — glossy tile + 3DS corner-bracket reticle on hover
---------------------------------------------------------------------------- */
.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  color: var(--ink);
  padding: 0;
  /* custom 3DS-style hand cursor (inline SVG data-URI), pointer fallback */
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M12 3c-1.1 0-2 .9-2 2v9L8.5 12.2c-.7-.9-2-1-2.8-.2-.7.7-.8 1.8-.2 2.6l4.6 6.7c.9 1.3 2.4 2.1 4 2.1h4.2c2.5 0 4.5-2 4.5-4.5V9c0-1.1-.9-2-2-2s-2 .9-2 2v-.5c0-1.1-.9-2-2-2s-2 .9-2 2V5c0-1.1-.9-2-2-2z' fill='%23ffffff' stroke='%232b8fd6' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 8 4, pointer;
  transition: transform 0.1s var(--ease-pop);
}
.app-card:focus-visible { outline: none; }
.app-card:active { transform: scale(0.97); }

.app-card__tile {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  font-size: clamp(1.9rem, 5.5vw, 2.7rem);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--gloss);
  overflow: visible;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.app-card__glyph { line-height: 1; }
/* logo images fill more of the tile than emoji do (but not edge-to-edge) */
.app-card__glyph.icon-img { width: 62%; height: 62%; }


/* crisp top gloss sheen */
.app-card__tile::before {
  content: "";
  position: absolute;
  inset: 0 0 58% 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}

/* 3DS corner-bracket reticle — hidden until hover/focus/selected */
.app-card__reticle {
  position: absolute;
  inset: -6px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.14s ease, transform 0.14s var(--ease-pop);
}
.app-card__reticle i {
  position: absolute;
  width: 14px; height: 14px;
  border: 3px solid var(--accent);
  border-radius: 3px;
}
.app-card__reticle i:nth-child(1) { top: 0; left: 0; border-right: none; border-bottom: none; }
.app-card__reticle i:nth-child(2) { top: 0; right: 0; border-left: none; border-bottom: none; }
.app-card__reticle i:nth-child(3) { bottom: 0; left: 0; border-right: none; border-top: none; }
.app-card__reticle i:nth-child(4) { bottom: 0; right: 0; border-left: none; border-top: none; }

.app-card:hover .app-card__reticle,
.app-card:focus-visible .app-card__reticle,
.app-card[aria-current="true"] .app-card__reticle {
  opacity: 1;
  transform: scale(1);
}
.app-card:hover .app-card__tile,
.app-card:focus-visible .app-card__tile { border-color: var(--accent); }

.app-card__label {
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hover speech bubble (appended to <body>, positioned by ui.js) */
.hover-bubble {
  position: absolute;
  z-index: 120;
  max-width: 220px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-screen), inset 0 1px 0 var(--gloss);
  color: var(--ink);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s var(--ease-pop);
}
.hover-bubble.is-visible { opacity: 1; transform: translateY(0); }
/* project type — plain blue circle w/ 2-letter acronym, top-right of the popup */
.hover-bubble__type {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.hover-bubble.has-type .hover-bubble__title { padding-right: 28px; }
.hover-bubble__title { font-family: var(--font-head); font-weight: 700; font-size: 0.9rem; margin-bottom: 3px; }
.hover-bubble__blurb { font-size: 0.8rem; line-height: 1.4; color: var(--ink-soft); margin-bottom: 6px; }
.hover-bubble__tags { display: flex; flex-wrap: wrap; gap: 4px; }
.hover-bubble__tag {
  font-size: 0.65rem; font-weight: 600;
  padding: 2px 6px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--accent);
  border: 1px solid var(--line);
}

/* ----------------------------------------------------------------------------
   6. TAGS + BUTTONS
---------------------------------------------------------------------------- */
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent-top), var(--accent-bot));
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), var(--shadow-card);
  transition: transform 0.12s var(--ease-pop), filter 0.15s ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3); }

.btn--ghost {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 var(--gloss), var(--shadow-card);
}

/* ----------------------------------------------------------------------------
   7. DETAIL MODAL ("game card")
---------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 20, 26, 0.5);
  backdrop-filter: blur(3px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.modal.is-open { opacity: 1; pointer-events: auto; }

.modal__card {
  position: relative;
  width: min(560px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-screen), inset 0 1px 0 var(--gloss);
  padding: 26px;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s var(--ease-pop);
}
.modal.is-open .modal__card { transform: translateY(0) scale(1); }

.modal__head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.modal__icon {
  font-size: 2.2rem;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--gloss);
  flex: none;
}
.modal__icon .icon-img { width: 72%; height: 72%; }
.modal__title { margin: 0; font-size: 1.45rem; }
.modal__type { font-size: 0.72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.modal__desc { line-height: 1.6; margin: 4px 0 16px; color: var(--ink); white-space: pre-line; }
.modal__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.modal__links { display: flex; flex-wrap: wrap; gap: 10px; }
.modal__images { display: grid; gap: 16px; margin-bottom: 18px; }
.modal__images img { width: 100%; border-radius: var(--radius-md); border: 1px solid var(--line); display: block; }
.modal__figure { margin: 0; }
.modal__figure figcaption { font-size: 0.85rem; line-height: 1.45; color: var(--ink-soft); margin-top: 6px; }
.modal__figure figcaption a { color: var(--accent); font-weight: 600; }
.modal__figure figcaption a:hover { text-decoration: underline; }

.modal__close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 1rem;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  box-shadow: inset 0 1px 0 var(--gloss);
  transition: filter 0.15s ease, transform 0.12s var(--ease-pop);
}
.modal__close:hover { filter: brightness(1.05); }
.modal__close:active { transform: translateY(1px); box-shadow: var(--inset); }

/* ----------------------------------------------------------------------------
   8. UTILITIES
---------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Icons rendered as plain <img> (reliable everywhere — no fragile CSS masks).
   Two kinds:
   - CHROME icons (nav / footer / contact) are monochrome #323942, authored for
     light mode; they invert to white in dark mode.
   - CONTENT logos (project & creative tiles, modal header, now-cards) keep their
     own colors in BOTH modes — never filtered.
   - Icons on a primary (blue) button are forced white in both modes for contrast. */
.icon-img {
  display: inline-block;
  width: 1em;
  height: 1em;
  object-fit: contain;
  vertical-align: -0.125em;
  transition: filter 0.35s ease;
}
/* chrome icons flip grey -> white in dark. NOT .about — those icons (pin, code,
   education) are colored / use their own dark-mode variants instead of a filter. */
html[data-theme="dark"] .nav .icon-img,
html[data-theme="dark"] .footer .icon-img,
html[data-theme="dark"] .contact .icon-img { filter: brightness(0) invert(1); }
/* icons sitting on a blue .btn are always white (both themes) */
.btn:not(.btn--ghost) .icon-img { filter: brightness(0) invert(1); }
/* the active (blue) home icon keeps its accent color — don't invert it in dark */
html[data-theme="dark"] .nav__home[aria-current="page"] .icon-img { filter: none; }
