/* Shared by every page. One dark theme, a tonal palette from the favicon's navy (#1e3a8a): deep navy surfaces,
   cool blue-gray text, pale blue headings, light blue links, lavender touches and a soft blue glow at the top. */

:root {
  color-scheme: dark;
  --bg: #0a1224;
  --glow: rgba(37, 78, 180, .28);
  --surface: #12203a;
  --border: #22324f;
  --fg: #e6ebf5;
  --muted: #9aa7c0;
  --accent: #93b4ff;
  --accent-hover: #bfd1ff;
  --accent-faint: rgba(147, 180, 255, .35);
  --card-hover-border: #3a5288;
  --heading: #bfd1ff;
  --lavender: #c4b5fd;
  --title-gradient: linear-gradient(90deg, var(--fg), var(--accent) 55%, var(--lavender));

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 48px;
  --radius: 12px;
  --content: 680px;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}

/* Fraunces (SIL Open Font License, site/fonts/OFL.txt) for headings and the name in the top bar; body text stays in
   the system font. Self-hosted, so visitors' browsers never contact a font service. Until it loads (or if it's
   blocked), headings show in the system font. Each page preloads it. */
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

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

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 90% 60% at 50% -10%, var(--glow), transparent 70%) no-repeat, var(--bg);
  color: var(--fg);
  font: 18px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---- Top bar: name on the left, tabs on the right ---- */

.topbar {
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.topbar-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--space-3);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--fg); }
.brand img { width: 28px; height: 28px; }

.tabs { display: flex; height: 100%; gap: var(--space-1); }

.tabs a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--space-3);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px; /* the active underline sits on the bar's border */
}
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Page content ---- */

main {
  flex: 1;
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-5) var(--space-3);
}

h1, h2 { font-family: var(--font-display); text-wrap: balance; }

h1 {
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0 0 var(--space-3);
}

/* Page titles fade from off-white through blue to lavender. fit-content makes the gradient span the words, not the
   whole column, so short titles like "About" get the full sweep. Browsers without background-clip: text keep the
   plain off-white. */
@supports (background-clip: text) or (-webkit-background-clip: text) {
  h1 {
    width: fit-content;
    background: var(--title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

h2 { color: var(--heading); font-size: 1.375rem; font-weight: 650; margin: var(--space-5) 0 var(--space-2); }

p { margin: 0 0 var(--space-3); }

.lede { font-size: 1.25rem; color: var(--muted); }

main ul { margin: 0 0 var(--space-3); padding-left: var(--space-4); }
main li { margin-bottom: var(--space-1); }
main li::marker { color: var(--lavender); }
cite { font-style: italic; }

/* The home page sits a little lower, so it reads as a landing page rather than an article. */
.home { display: flex; flex-direction: column; justify-content: center; padding-bottom: 15vh; }

/* The headline stays on one line: it scales down on phones (fits from about 360px wide). */
.home .lede { font-size: clamp(1rem, 4.4vw, 1.25rem); }

/* ---- Footer ---- */

.footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--muted);
  font-size: 14px;
}

.footer a { display: flex; color: var(--muted); }
.footer a:hover { color: var(--accent); }
.footer svg { width: 20px; height: 20px; fill: currentColor; }

@media (max-width: 359px) {
  .brand span { display: none; } /* the JP mark alone, so the tabs keep their room */
}

/* ---- Page transitions (View Transitions API) ----
   Navigating between pages cross-fades instead of flashing white. The top bar and footer stay put, the active tab
   slides to the new tab, and the page title moves from its old spot to its new one. CSS only: browsers without
   support (and visitors who ask for reduced motion) just navigate normally. */

@view-transition { navigation: auto; }

.topbar { view-transition-name: topbar; }
.footer { view-transition-name: footer; }
.tabs a[aria-current="page"] { view-transition-name: active-tab; }
h1 { view-transition-name: page-title; }

::view-transition-group(*) { animation-duration: .35s; animation-timing-function: cubic-bezier(.2, 0, 0, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .25s; }

/* Keep the title and tab at their natural size while they move, instead of stretching between the old and new
   widths ("Jacob Pokora" is much wider than "About"). */
::view-transition-old(page-title), ::view-transition-new(page-title),
::view-transition-old(active-tab), ::view-transition-new(active-tab) { width: auto; height: auto; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---- Links in the page text ----
   A faint underline at rest (so links stay recognizable), and a full-strength one that grows in from the left on
   hover. Drawn with two background layers instead of text-decoration so the growth can animate; `clone` keeps it
   right on links that wrap onto a second line. */

main a:not(.card) {
  text-decoration: none;
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(var(--accent-faint), var(--accent-faint));
  background-size: 0% 1px, 100% 1px;
  background-position: 0 100%, 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
main a:not(.card):hover { background-size: 100% 1px, 100% 1px; }

/* ---- Home cards ----
   A bento grid: Music is the large feature tile on the left, Reading and Games stack beside it. Each card is one
   link into its section of About. On phones they stack in a single column. */

.cards {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 12px;
  margin-top: var(--space-4);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
}
.card:hover { color: var(--muted); border-color: var(--card-hover-border); }
.card h2 { margin: 0; color: var(--fg); font-size: 1.1rem; }
.card p { margin: 0; }

.card-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--lavender);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-feature {
  grid-row: span 2;
  justify-content: flex-end;
  min-height: 230px;
  background:
    radial-gradient(circle at 80% 15%, rgba(196, 181, 253, .22), transparent 55%),
    linear-gradient(160deg, #1a2c52, var(--surface));
}
.card-feature .card-icon { width: 34px; height: 34px; margin-bottom: auto; }
.card-feature h2 { font-size: 1.4rem; }
.card-more { color: var(--accent); font-size: 14px; font-weight: 500; }
.card-more span { display: inline-block; }

@media (max-width: 559px) {
  .cards { grid-template-columns: 1fr; }
  .card-feature { grid-row: auto; min-height: 180px; }
}

/* ---- Motion: entrance and micro-interactions ----
   Everything below only applies to visitors who haven't asked for reduced motion; they get the same end states
   without the movement. Hover effects are limited to devices with a real pointer, so taps on phones don't leave
   things stuck in their hover state. */

@keyframes title-in { from { opacity: 0; filter: blur(8px); } }
@keyframes rise-in { from { opacity: 0; translate: 0 14px; } }

@media (prefers-reduced-motion: no-preference) {
  /* Home: the name comes into focus, then the headline rises in just after it. The name only fades and unblurs
     (no movement), so it doesn't fight the page transition when arriving from another page, which moves it. */
  .home h1 { animation: title-in .9s cubic-bezier(.2, 0, 0, 1) both; }
  .home .lede { animation: rise-in .8s cubic-bezier(.2, 0, 0, 1) .25s both; }
  /* backwards, not both: the animation lets go when it ends, so the hover lift still works. */
  .home .card { animation: rise-in .8s cubic-bezier(.2, 0, 0, 1) backwards; }
  .home .card:nth-child(1) { animation-delay: .4s; }
  .home .card:nth-child(2) { animation-delay: .5s; }
  .home .card:nth-child(3) { animation-delay: .6s; }

  a, .tabs a { transition: color .2s ease; }
  main a:not(.card) { transition: background-size .35s cubic-bezier(.2, 0, 0, 1), color .2s ease; }
  .card { transition: border-color .25s ease, translate .25s cubic-bezier(.2, 0, 0, 1), box-shadow .25s ease; }
  .card-more span { transition: translate .25s cubic-bezier(.2, 0, 0, 1); }
  .tabs a::after { transition: scale .3s cubic-bezier(.2, 0, 0, 1); }
  .brand img { transition: rotate .4s cubic-bezier(.2, 0, 0, 1), scale .4s cubic-bezier(.2, 0, 0, 1); }
  .footer a { transition: color .2s ease, translate .2s ease; }
}

/* Tabs: an underline grows out from the middle of a tab you hover, fainter than the active tab's, so it previews it
   without competing. It sits exactly where the active tab's border does. */
.tabs a { position: relative; }
.tabs a::after {
  content: "";
  position: absolute;
  inset: auto 0 -3px;
  height: 3px;
  background: var(--accent-faint);
  scale: 0 1;
}

@media (hover: hover) {
  .tabs a:not([aria-current="page"]):hover::after { scale: 1 1; }
}

/* The JP mark tilts and the GitHub icon lifts on hover: movement only, so reduced motion skips them entirely. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .brand:hover img { rotate: -8deg; scale: 1.08; }
  .footer a:hover { translate: 0 -2px; }
  .card:hover { translate: 0 -3px; box-shadow: 0 8px 24px -12px rgba(147, 180, 255, .35); }
  .card:hover .card-more span { translate: 3px 0; }
}

/* ---- Scroll reveals (About) ----
   Each section fades and rises in as it scrolls into view, driven by the scroll position itself (CSS scroll-driven
   animations), not a timer: it's fully in place by the time it's 40% of the way into the viewport, and scrolling back
   up plays it in reverse. Sections already on screen when the page loads (or when following a link like
   /about#music) are already past that point, so they just show. Browsers without support, and visitors who ask for
   reduced motion, see every section normally. */

@keyframes reveal { from { opacity: 0; translate: 0 32px; } }

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    main > section {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }
}
