/* ---------- Font (self-hosted, SIL OFL) ---------- */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/nunito-latin.woff2") format("woff2");
}

/* ---------- Design tokens: tweak colours and sizing here ---------- */
/* Dark is the default; light applies via the switch or the OS preference. */
:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --glow: rgba(139, 156, 255, .08);
  --surface: #121216;
  --border: #23232b;
  --chip-border: #2c2c36;
  --text: #ececf1;
  --muted: #a3a3b2;
  --accent: #8b9cff;          /* lavender-blue */
  --accent-soft: rgba(139, 156, 255, .12);

  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --gap: clamp(.5rem, 1.6vh, 1rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f7fa;
  --glow: rgba(79, 99, 224, .08);
  --surface: #ffffff;
  --border: #e3e3ea;
  --chip-border: #dcdce6;
  --text: #17171c;
  --muted: #5b5b6b;
  --accent: #4655d6;
  --accent-soft: rgba(70, 85, 214, .09);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f7f7fa;
    --glow: rgba(79, 99, 224, .08);
    --surface: #ffffff;
    --border: #e3e3ea;
    --chip-border: #dcdce6;
    --text: #17171c;
    --muted: #5b5b6b;
    --accent: #4655d6;
    --accent-soft: rgba(70, 85, 214, .09);
  }
}

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

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

body {
  margin: 0;
  background:
    radial-gradient(60rem 30rem at 50% -10%, var(--glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Page frame: fills the viewport, honours safe areas ---------- */
.page {
  min-height: 100vh;       /* fallback */
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
  width: min(100%, 60rem);
  margin-inline: auto;
  padding:
    max(clamp(1rem, 4vh, 2.5rem), env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
}

/* ---------- Intro ---------- */
.intro {
  text-align: center;
  padding-top: clamp(.25rem, 3vh, 2rem);
}
.name {
  margin: 0;
  font-size: clamp(2.5rem, 8vh, 4.5rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.role {
  margin: .5rem 0 0;
  font-family: var(--mono);
  font-size: clamp(.8rem, 1.9vh, .95rem);
  color: var(--accent);
  letter-spacing: .02em;
}
.tagline {
  margin: .75rem auto 0;
  max-width: 34rem;
  font-size: clamp(.95rem, 2.4vh, 1.15rem);
  color: var(--muted);
}

/* ---------- Skill groups ---------- */
.groups {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}
.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: clamp(.6rem, 1.8vh, 1rem) clamp(.8rem, 2vw, 1.1rem);
}
.group--wide { grid-column: 1 / -1; }

.group h2 {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .85rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
}
.group h2 .icon { color: var(--accent); }

.skills {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .4rem;
}
.skills li {
  padding: .1rem .6rem;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Contact ---------- */
.contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  padding-top: var(--gap);
  border-top: 1px solid var(--border);
}
.contact-text { margin: 0; color: var(--muted); font-size: .95rem; }
.links { list-style: none; margin: 0; padding: 0; display: flex; gap: .5rem; }

.links a,
.links .copy {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}
.links a:hover,
.links .copy:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.links a:focus-visible,
.links .copy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Icons ---------- */
.icon {
  width: 1rem;
  height: 1rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Theme switch ---------- */
.page { position: relative; }
.theme-toggle {
  position: absolute;
  top: max(.75rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-toggle .icon--sun { display: none; }
/* Show the icon of the theme you would switch to. */
:root[data-theme="dark"] .theme-toggle .icon--moon,
:root:not([data-theme]) .theme-toggle .icon--moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon--sun,
:root:not([data-theme]) .theme-toggle .icon--sun { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon--moon { display: block; }
  :root:not([data-theme]) .theme-toggle .icon--sun { display: none; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Short desktop screens: tighten further ---------- */
@media (min-width: 721px) and (max-height: 760px) {
  .group h2 { margin-bottom: .6rem; }
  .skills { font-size: .8rem; }
  .contact-text { font-size: .875rem; }
}

/* ---------- Mobile: single column, scrolling allowed ---------- */
@media (max-width: 720px) {
  .groups { grid-template-columns: 1fr; align-self: start; }
  .group--wide { grid-column: auto; }
  .intro { padding-top: 1rem; }
  .contact { flex-direction: column; align-items: flex-start; }
  .links { flex-wrap: wrap; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
