/* ==========================================================================
   Wilbert Cheng — Portfolio
   Shared styles for all pages
   ========================================================================== */

:root {
  /* Warm-dark theme (after marcuslorenzet.com) */
  --bg: #11100d;
  --surface: #161511;
  --surface-2: #1d1b16;
  --ink: #d0c5ab;
  --ink-soft: rgba(208, 197, 171, 0.8);
  --ink-muted: rgba(208, 197, 171, 0.6);
  --ink-faint: rgba(208, 197, 171, 0.18);
  --line: rgba(208, 197, 171, 0.14);
  --accent: #d0c5ab;
  --on-accent: #11100d;

  --font: "Plus Jakarta Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-alt: "Urbanist", "Plus Jakarta Sans", sans-serif;
  --max: 1280px;
  --gutter: clamp(16px, 4vw, 56px);
  --section: clamp(64px, 9vw, 120px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 19px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

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

/* ---------- Small type ---------- */
.eyebrow {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
/* "[ LABEL ]" style used for section labels */
.bracket::before { content: "[ "; }
.bracket::after { content: " ]"; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  transition: opacity .2s ease;
}
.btn:hover { opacity: .85; }
.btn svg { width: 14px; height: 14px; }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
}
.link-arrow svg { width: 14px; height: 14px; transition: transform .25s ease; }
.link-arrow:hover svg { transform: translateX(4px); }

/* ---------- Header (sits over the hero, scrolls away) ---------- */
.site-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 40;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 84px;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.header-mail {
  font-size: 16px;
  color: var(--ink-soft);
  transition: color .2s ease;
}
.header-mail:hover { color: var(--ink); }

/* ---------- Floating pill nav ---------- */
.pill-nav {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.pill-nav a {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-soft);
  transition: color .2s ease;
}
.pill-nav a:hover,
.pill-nav a[aria-current="page"] { color: var(--ink); }
.pill-nav a.btn { margin-left: 8px; padding: 14px 20px; color: var(--on-accent); font-weight: 800; }

/* ---------- Section header (01 — LABEL ...... LINK) ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
}
.section-head .index {
  display: flex;
  align-items: center;
  gap: 24px;
}
.section-head .num {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-muted);
}
.section-head .eyebrow { line-height: 1.5; }

/* ---------- Image placeholders ----------
   Swap these for real <img> tags when assets are ready.
   Warm, low-light tones to sit on the dark theme. */
.ph {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background:
    radial-gradient(ellipse 60% 80% at 15% 20%, rgba(0,0,0,.4), transparent 60%),
    radial-gradient(ellipse 50% 60% at 85% 90%, rgba(208,197,171,.08), transparent 60%),
    linear-gradient(135deg, #2a2720, #161511);
}
.ph--light {
  background:
    radial-gradient(ellipse 70% 60% at 80% 10%, rgba(0,0,0,.25), transparent 60%),
    linear-gradient(160deg, #6b6455, #3a362d);
}
.ph--leaf {
  background:
    radial-gradient(ellipse 30% 45% at 40% 45%, #4a4436, transparent 70%),
    radial-gradient(ellipse 25% 40% at 65% 55%, #3b362b, transparent 70%),
    linear-gradient(135deg, #2f2b23, #1b1914);
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 28px 0 40px;
  font-size: 14px;
  color: var(--ink-muted);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .header-mail { display: none; }
  .pill-nav { bottom: 16px; }
  .pill-nav a { padding: 10px 9px; font-size: 13px; }
  .pill-nav a.btn { margin-left: 4px; padding: 12px 14px; }
}

/* ---------- Page transition ----------
   The curtain is in the HTML so it covers the page before anything paints,
   then slides up and away with pure CSS (works even if JS fails).
   js/main.js adds .is-leaving on link clicks to slide it back in. */
.page-transition {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  padding: var(--gutter);
  padding-bottom: clamp(32px, 6vh, 64px);
  background: var(--accent);
  color: var(--on-accent);
  pointer-events: none;
  animation: pt-reveal .85s cubic-bezier(.76, 0, .24, 1) .15s both;
}
.page-transition span {
  font-size: clamp(56px, 13vw, 200px);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: .85;
  text-transform: uppercase;
  animation: pt-label-out .6s cubic-bezier(.76, 0, .24, 1) .15s both;
}
.page-transition.is-leaving {
  pointer-events: all;
  animation: pt-cover .7s cubic-bezier(.76, 0, .24, 1) both;
}
.page-transition.is-leaving span {
  animation: pt-label-in .55s cubic-bezier(.22, 1, .36, 1) .25s both;
}
@keyframes pt-reveal { from { transform: translateY(0); } to { transform: translateY(-100%); } }
@keyframes pt-cover  { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pt-label-out { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-40%); opacity: 0; } }
@keyframes pt-label-in  { from { transform: translateY(40%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .page-transition { display: none; }
}

/* ==========================================================================
   Light theme — the default (data-theme="light" on <html>); the nav toggle switches to dark
   ========================================================================== */
:root { color-scheme: dark; }
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f6f6f5;
  --surface-2: #eeeeec;
  --ink: #161616;
  --ink-soft: rgba(22, 22, 22, 0.76);
  --ink-muted: rgba(22, 22, 22, 0.56);
  --ink-faint: rgba(22, 22, 22, 0.14);
  --line: rgba(22, 22, 22, 0.1);
  --accent: #161616;
  --on-accent: #ffffff;
}
:root[data-theme="light"] .ph {
  background:
    radial-gradient(ellipse 60% 80% at 15% 20%, rgba(0,0,0,.12), transparent 60%),
    radial-gradient(ellipse 50% 60% at 85% 90%, rgba(255,255,255,.4), transparent 60%),
    linear-gradient(135deg, #d6d6d3, #b9b9b5);
}
:root[data-theme="light"] .ph--light {
  background:
    radial-gradient(ellipse 70% 60% at 80% 10%, rgba(0,0,0,.08), transparent 60%),
    linear-gradient(160deg, #ededeb, #d3d3d0);
}
:root[data-theme="light"] .ph--leaf {
  background:
    radial-gradient(ellipse 30% 45% at 40% 45%, #9ea47c, transparent 70%),
    radial-gradient(ellipse 25% 40% at 65% 55%, #868c66, transparent 70%),
    linear-gradient(135deg, #b7b596, #8d8f6c);
}
:root[data-theme="light"] .pill-nav { box-shadow: 0 10px 40px rgba(0, 0, 0, .1); }

/* Smooth colour change while switching themes (class added briefly by js/main.js) */
.theme-switching,
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: background-color .45s ease, color .45s ease, border-color .45s ease, box-shadow .45s ease !important;
}

/* ---------- Theme toggle (in the pill nav) ---------- */
.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s ease;
}
.theme-toggle:hover { border-color: var(--ink-muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.theme-toggle svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  transition: transform .5s cubic-bezier(.22, 1, .36, 1), opacity .3s ease;
}
/* Dark theme shows the sun (switch to light); light theme shows the moon */
.theme-toggle .i-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
:root[data-theme="light"] .theme-toggle .i-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
:root[data-theme="light"] .theme-toggle .i-moon { opacity: 1; transform: none; }

@media (max-width: 760px) {
  .pill-nav { gap: 2px; padding: 6px; }
  .pill-nav a { padding: 10px 7px; }
  .theme-toggle { width: 36px; height: 36px; margin-left: 2px; }
}

/* Read by screen readers, hidden on screen */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
