/* =====================================================================
   Mohan George · Portfolio v2 — core system
   Shared by every page: tokens, type, top bar, logo, overlay menu,
   theme picker, "Let's talk" dialog and contact form, footer.
   The whole palette is derived from one number, --h (theme hue),
   set by theme.js on load and by the theme picker.
   ===================================================================== */

@font-face { font-family: "Unbounded"; src: url("../fonts/unbounded-latin-300-normal.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("../fonts/unbounded-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("../fonts/unbounded-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("../fonts/unbounded-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("../fonts/unbounded-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-latin-wght-italic.woff2") format("woff2-variations"); font-weight: 400 700; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* Registering --h lets the whole site glide between colours. */
@property --h { syntax: "<number>"; inherits: true; initial-value: 222; }

:root {
  --h: 222;
  --h2: calc(var(--h) + 48);

  --bg:        hsl(var(--h) 48% 4.6%);
  --bg-2:      hsl(var(--h) 42% 7%);
  --panel:     hsl(var(--h) 34% 9.5% / .78);
  --panel-2:   hsl(var(--h) 30% 13%);
  --line:      hsl(var(--h) 60% 85% / .10);
  --line-2:    hsl(var(--h) 60% 85% / .2);
  --ink:       hsl(var(--h) 35% 96%);
  --ink-2:     hsl(var(--h) 18% 78%);
  --muted:     hsl(var(--h) 14% 62%);
  --dim:       hsl(var(--h) 14% 40%);
  --accent:    hsl(var(--h) 96% 66%);
  --accent-2:  hsl(var(--h2) 92% 68%);
  --accent-ink:hsl(var(--h) 60% 7%);
  --glow:      hsl(var(--h) 96% 60% / .35);
  --glow-soft: hsl(var(--h) 96% 60% / .14);
  --grad:      linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 100%);

  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --wrap: 1240px;
  --gutter: clamp(20px, 4vw, 40px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --r-sm: 10px;
  --r-md: 18px;
  --r-lg: 28px;

  transition: --h 1.1s var(--ease);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-locked { overflow: hidden; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ambient light: two soft pools that follow the theme colour */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 50vh at 85% -10%, hsl(var(--h) 90% 50% / .14), transparent 70%),
    radial-gradient(50vw 60vh at -10% 110%, hsl(var(--h2) 90% 55% / .08), transparent 70%),
    var(--bg);
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 300; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.skip:focus { top: 12px; }

/* ---------- Type ---------- */
.h1, .h2, .h3 { font-family: var(--display); font-weight: 500; letter-spacing: -0.02em; margin: 0; }
.h2 { font-size: clamp(30px, 4.2vw, 56px); line-height: 1.08; }
.h3 { font-size: clamp(19px, 1.6vw, 22px); line-height: 1.25; font-weight: 500; }
.lead { font-size: clamp(17px, 1.35vw, 19px); color: var(--ink-2); max-width: 62ch; }
.num { font-family: var(--display); font-feature-settings: "tnum"; }

/* Section heading row: index + name. The index mirrors the spine nav. */
.sec-head { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; color: var(--muted); font-size: 14px; }
.sec-head__idx { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.sec-head__line { flex: 0 0 48px; height: 1px; background: linear-gradient(90deg, var(--accent), transparent); }

/* Scroll-filled headings: the ink sweeps in as the heading crosses the viewport. */
.fill {
  --p: 0;
  color: transparent;
  background-image: linear-gradient(90deg, var(--ink) 0 50%, hsl(var(--h) 20% 28%) 50% 100%);
  background-size: 200% 100%;
  background-position: calc((1 - var(--p)) * 100%) 0;
  -webkit-background-clip: text;
  background-clip: text;
}

/* ---------- Buttons ---------- */
.btn {
  --bh: 52px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--bh); padding: 0 24px; border-radius: 100px;
  font-weight: 600; font-size: 15px; letter-spacing: .01em;
  border: 1px solid var(--line-2); color: var(--ink);
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), box-shadow .3s var(--ease), transform .25s var(--ease);
  white-space: nowrap;
}
.btn i { font-size: 1.05em; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
/* Solid buttons: white by default, take on the theme gradient on hover / focus */
.btn--solid { background: var(--solid-bg, #fff); color: var(--solid-ink, hsl(var(--h) 45% 8%)); border-color: transparent; box-shadow: 0 10px 30px -14px hsl(0 0% 100% / .35); background-size: 100% 100%; }
.btn--solid:hover, .btn--solid:focus-visible { background: var(--grad); color: var(--accent-ink); border-color: transparent; box-shadow: 0 16px 44px -10px var(--glow); transform: translateY(-1px); }
.btn--sm { --bh: 42px; padding: 0 18px; font-size: 14px; }
.btn--icon { width: var(--bh); padding: 0; }
.link-arrow { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); border-bottom: 1px solid currentColor; padding-bottom: 2px; }
.link-arrow i { transition: transform .25s var(--ease); }
.link-arrow:hover i { transform: translate(3px, -3px); }

/* ---------- Top bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 90;
  transition: background .35s var(--ease), border-color .35s var(--ease), transform .4s var(--ease);
  border-bottom: 1px solid transparent;
}
.bar.is-solid { background: hsl(var(--h) 45% 5% / .72); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); border-color: var(--line); }
.bar.is-hidden { transform: translateY(-100%); }
.bar__inner { height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1400px; margin: 0 auto; padding: 0 var(--gutter); }
.bar__right { display: flex; align-items: center; gap: 10px; }

/* ---------- Logo: one continuous stroke draws an M that turns into a G ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand__mark { width: 40px; height: 40px; flex: none; overflow: visible; }
.brand__chip { fill: hsl(var(--h) 45% 11% / .85); stroke: url(#mgStroke); stroke-width: 1.2; stroke-opacity: .45; }
.brand__path {
  fill: none; stroke: url(#mgStroke); stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 120; stroke-dashoffset: 120;
  animation: mg-draw 1.6s var(--ease) .2s forwards;
}
.brand__dot { fill: var(--accent-2); transform-origin: 33px 15.4px; animation: mg-dot 2.8s ease-in-out 1.6s infinite; opacity: 0; }
.brand:hover .brand__path { animation: mg-draw 1.1s var(--ease) both; }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name { font-family: var(--display); font-weight: 500; font-size: 18px; letter-spacing: -0.01em; }
.brand__role { font-size: 15px; color: var(--muted); margin-top: 3px; }
@keyframes mg-draw { from { stroke-dashoffset: 120; } to { stroke-dashoffset: 0; } }
@keyframes mg-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(1.7); } }

.menu-btn { display: inline-flex; align-items: center; gap: 12px; height: 42px; padding: 0 6px 0 14px; border-radius: 100px; font-size: 14px; font-weight: 600; }
.menu-btn__lines { width: 26px; display: grid; gap: 5px; }
.menu-btn__lines span { height: 2px; background: currentColor; border-radius: 2px; transition: transform .35s var(--ease), width .35s var(--ease); }
.menu-btn__lines span:nth-child(2) { width: 65%; justify-self: end; }
.menu-btn:hover .menu-btn__lines span:nth-child(2) { width: 100%; }

/* ---------- Full-screen menu ---------- */
.menu {
  position: fixed; inset: 0; z-index: 120;
  background: hsl(var(--h) 50% 4% / .96);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  display: grid; grid-template-rows: auto 1fr; overflow-y: auto;
  clip-path: circle(0% at calc(100% - 60px) 38px);
  visibility: hidden;
  transition: clip-path .7s var(--ease), visibility 0s linear .7s;
}
.menu.is-open { clip-path: circle(150% at calc(100% - 60px) 38px); visibility: visible; transition: clip-path .8s var(--ease), visibility 0s; }
.menu__top { height: 76px; display: flex; align-items: center; justify-content: space-between; max-width: 1400px; width: 100%; margin: 0 auto; padding: 0 var(--gutter); }
.menu__close { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 18px; transition: transform .4s var(--ease), border-color .3s; }
.menu__close:hover { transform: rotate(90deg); border-color: var(--accent); }
.menu__body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: end; max-width: 1400px; width: 100%; margin: 0 auto; padding: 20px var(--gutter) 48px; }
.menu__links { list-style: none; margin: 0; padding: 0; counter-reset: m; }
.menu__links a {
  display: flex; align-items: baseline; gap: 18px; padding: 6px 0;
  font-family: var(--display); font-weight: 500; font-size: clamp(30px, 5.4vh, 60px); line-height: 1.12; letter-spacing: -0.03em;
  color: var(--ink-2); transition: color .3s, transform .4s var(--ease);
  opacity: 0; transform: translateY(24px);
}
.menu.is-open .menu__links a { opacity: 1; transform: none; transition: color .3s, opacity .5s var(--ease) calc(.15s + var(--i) * .06s), transform .6s var(--ease) calc(.15s + var(--i) * .06s); }
.menu__links a small { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: 0; }
.menu__links a:hover, .menu__links a.is-active { color: var(--ink); }
.menu__links a:hover { transform: translateX(10px); }
.menu__aside { display: grid; gap: 22px; color: var(--ink-2); font-size: 15px; padding-bottom: 8px; }
.menu__aside a:hover { color: var(--accent); }
.menu__aside p { margin: 0; display: flex; gap: 10px; align-items: center; }
.menu__aside .btn { justify-self: start; }

/* ---------- Theme picker ---------- */
.tp { position: fixed; right: 20px; bottom: 20px; z-index: 95; }
.tp__toggle {
  width: 52px; height: 52px; border-radius: 50%;
  background: hsl(var(--h) 40% 10% / .8); border: 1px solid var(--line-2);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center; position: relative;
  box-shadow: 0 10px 30px -10px #000;
}
.tp__toggle::before {
  content: ""; width: 24px; height: 24px; border-radius: 50%;
  background: conic-gradient(from 0deg, hsl(0 90% 62%), hsl(60 90% 62%), hsl(120 90% 55%), hsl(180 90% 58%), hsl(240 90% 66%), hsl(300 90% 64%), hsl(360 90% 62%));
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--accent);
  transition: transform .6s var(--ease);
}
.tp__toggle:hover::before { transform: rotate(180deg); }
.tp__panel {
  position: absolute; right: 0; bottom: 64px; width: 292px;
  background: hsl(var(--h) 40% 7% / .94); border: 1px solid var(--line-2); border-radius: var(--r-md);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  padding: 18px; box-shadow: 0 24px 60px -20px #000;
  opacity: 0; transform: translateY(10px) scale(.98); transform-origin: bottom right; pointer-events: none;
  transition: opacity .25s var(--ease), transform .3s var(--ease);
}
.tp.is-open .tp__panel { opacity: 1; transform: none; pointer-events: auto; }
.tp__title { margin: 0 0 4px; font-family: var(--display); font-size: 15px; font-weight: 500; }
.tp__hint { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.tp__swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.tp__sw {
  aspect-ratio: 1; border-radius: 12px; position: relative;
  background: radial-gradient(circle at 30% 30%, hsl(var(--sh) 96% 72%), hsl(var(--sh) 80% 42%) 70%), hsl(var(--sh) 48% 5%);
  border: 1px solid hsl(0 0% 100% / .12);
  transition: transform .2s var(--ease);
}
.tp__sw:hover { transform: translateY(-2px); }
.tp__sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px hsl(var(--sh) 96% 66%); }
.tp__label { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.tp__label output { font-family: var(--mono); color: var(--muted); }
.tp__hue { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 10px; outline-offset: 4px;
  background: linear-gradient(90deg, hsl(0 90% 60%), hsl(60 90% 60%), hsl(120 90% 55%), hsl(180 90% 55%), hsl(240 90% 66%), hsl(300 90% 64%), hsl(360 90% 60%)); }
.tp__hue::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); box-shadow: 0 2px 8px #0008; cursor: grab; }
.tp__hue::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); cursor: grab; }
.tp__row { display: flex; gap: 8px; margin-top: 16px; }
.tp__row .btn { flex: 1; }

/* ---------- Dialog base (talk + viewer) ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: hsl(var(--h) 60% 3% / .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.talk {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: radial-gradient(120% 60% at 100% 0%, hsl(var(--h) 80% 30% / .35), transparent 60%), hsl(var(--h) 40% 6.5%);
  box-shadow: 0 40px 120px -30px #000, 0 0 0 1px hsl(var(--h) 90% 70% / .06) inset;
  overflow: auto;
}
.talk[open] { animation: dlg-in .45s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
.talk__inner { padding: clamp(24px, 4vw, 40px); }
.talk__head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 24px; }
.talk__head h2 { font-family: var(--display); font-weight: 500; font-size: clamp(24px, 3vw, 32px); margin: 0 0 6px; letter-spacing: -0.02em; }
.talk__head p { margin: 0; color: var(--muted); font-size: 15px; }
.x-btn { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; transition: transform .35s var(--ease), border-color .25s; }
.x-btn:hover { transform: rotate(90deg); border-color: var(--accent); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 16px; }
.field { display: grid; gap: 7px; }
.field--full { grid-column: 1 / -1; }
.field label, .field legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; }
.field label span { color: var(--muted); font-weight: 400; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: hsl(var(--h) 40% 12% / .55); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 13px 14px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow-soft); background: hsl(var(--h) 40% 14% / .7); }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: hsl(355 90% 65%); }
.field__err { font-size: 13px; color: hsl(355 90% 72%); min-height: 0; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 9px 14px; border-radius: 100px; border: 1px solid var(--line-2); font-size: 14px; color: var(--ink-2); cursor: pointer; transition: all .2s var(--ease); }
.chip input:checked + span { background: var(--glow-soft); border-color: var(--accent); color: var(--ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form__foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.form__note { font-size: 13px; color: var(--muted); margin: 0; }
.form__status { grid-column: 1 / -1; font-size: 14px; margin: 0; }
.form__status.is-error { color: hsl(355 90% 72%); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.talk__done { text-align: center; padding: 24px 0 8px; }
.talk__done-icon { width: 76px; height: 76px; margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; background: var(--grad); color: var(--accent-ink); box-shadow: 0 0 0 10px var(--glow-soft), 0 20px 50px -10px var(--glow); }
.talk__done h3 { font-family: var(--display); font-weight: 500; font-size: 26px; margin: 0 0 8px; }
.talk__done p { color: var(--ink-2); margin: 0 auto 24px; max-width: 42ch; }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 28px 0; font-size: 14px; color: var(--muted); }
.foot__inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.foot__links { display: flex; gap: 18px; align-items: center; }
.foot__links a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .menu__body { grid-template-columns: 1fr; align-items: start; }
  .brand__role { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .bar__inner { height: 64px; }
  .bar .btn--talk { --bh: 40px; padding: 0 14px; font-size: 13px; }
  .menu-btn__label { display: none; }
  .brand__name { font-size: 13px; }
  .brand__mark { width: 34px; height: 34px; }
  .form { grid-template-columns: 1fr; }
  .tp { right: 14px; bottom: 14px; }
  .tp__toggle { width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .brand__path { stroke-dashoffset: 0; }
  .fill { --p: 1 !important; }
}
