/* ==========================================================================
   garethmcauley.com — bold & modern, mobile-first
   ========================================================================== */

:root {
  /* Rebrand the whole site by changing these three */
  --accent: #6c5ce7;        /* electric indigo */
  --accent-bright: #a29bfe;
  --bg: #0b0c15;            /* near-black */

  --bg-raised: #141623;
  --text: #f2f3f7;
  --text-muted: #9aa0b4;
  --border: #262a3d;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Fluid spacing & type */
  --space-section: clamp(4rem, 12vw, 9rem);
  --pad-x: max(1.25rem, env(safe-area-inset-left), env(safe-area-inset-right));
}

/* Scroll-driven colour themes: js/main.js interpolates --accent, --bg etc.
   from the scroll position each frame (palettes defined there). No CSS
   transitions here — the per-frame inline values ARE the animation, and a
   transition would lag behind the scroll. Without JS the site stays on the
   indigo :root palette. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 0.5rem 0.5rem;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

.accent { color: var(--accent-bright); }

/* ============ Header / nav ============ */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 64rem;
  margin-inline: auto;
  padding: 0.75rem var(--pad-x);
}

.brand {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}
.brand-dot { color: var(--accent-bright); }

.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;   /* iOS minimum touch target */
  height: 44px;
  background: none;
  border: 0;
  cursor: pointer;
}

.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  content: "";
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
.nav-toggle-bar { position: relative; }
.nav-toggle-bar::before { position: absolute; top: -7px; }
.nav-toggle-bar::after  { position: absolute; top: 7px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after  { transform: translateY(-7px) rotate(-45deg); }

.nav-links {
  list-style: none;
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  flex-direction: column;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.nav-links.open { display: flex; }

.nav-links a {
  display: block;
  padding: 0.9rem var(--pad-x);  /* generous tap area */
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.nav-links a:active,
.nav-links a:hover { color: var(--accent-bright); }

@media (min-width: 40rem) {
  .nav-toggle { display: none; }
  .nav-links {
    display: flex;
    position: static;
    flex-direction: row;
    gap: 0.25rem;
    background: none;
    border: 0;
  }
  .nav-links a { padding: 0.5rem 0.85rem; border-radius: 0.5rem; }
}

/* ============ Hero ============ */

.hero {
  min-height: 100svh;   /* small viewport height: stable on iOS Safari */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6rem var(--pad-x) 3rem;
  max-width: 64rem;
  margin-inline: auto;
  background:
    radial-gradient(ellipse 80% 55% at 75% 15%, color-mix(in srgb, var(--accent) 28%, transparent), transparent),
    radial-gradient(ellipse 60% 45% at 10% 90%, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
}

.hero-title {
  /* One line: "Hello, I'm Gareth." — sized so it fits a phone screen */
  font-size: clamp(2.4rem, 10vw, 6rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: 1.5rem;
}

.hero-hello {
  font-weight: 600;
  color: var(--accent-bright);
}

.hero-tagline {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: var(--text-muted);
  max-width: 36ch;
  margin-bottom: 2.5rem;
}
/* Each phrase wraps as a unit — no mid-phrase line breaks */
.hero-tagline span { white-space: nowrap; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;   /* comfortable thumb target */
  padding: 0.75rem 1.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-bright); color: var(--bg); }

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent-bright); color: var(--accent-bright); }

/* ============ Sections ============ */

.section {
  max-width: 64rem;
  margin-inline: auto;
  padding: var(--space-section) var(--pad-x) 0;
}

.section-title {
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 2.25rem;
}

.subsection-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============ Clarity / "Clear Business Processes" novelty ============ */

.clarity-section {
  max-width: 64rem;
  margin-inline: auto;
  padding: var(--space-section) var(--pad-x) 0;
  text-align: center; /* centres the refresh button */
}

.clarity-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(160px, 32vw, 280px);
  /* No box — sits on the page background; the canvas cover matches it so the
     text is hidden until wiped. */
  touch-action: pan-y; /* allow vertical scroll, we use horizontal-ish wipes */
  /* Stop iOS selecting/highlighting the hidden text on press-and-hold */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.clarity-text {
  margin: 0;
  padding: 0 1rem;
  width: 100%;
  text-align: center;
  font-size: clamp(1.9rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
}

/* The accent word in each phrase, revealed with the rest as you wipe */
.clarity-word-clear { color: var(--accent-bright); }

/* Refresh button — appears after the reveal to pick a new phrase.
   Always occupies its space (visibility, not display) so revealing it
   doesn't shift the page below. */
.clarity-refresh {
  display: inline-flex;
  visibility: hidden;
  pointer-events: none;
  margin: 1.5rem auto 0;
  padding: 0.5rem 1.1rem;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, opacity 0.3s;
  opacity: 0;
}
.clarity-refresh.is-visible { visibility: visible; pointer-events: auto; opacity: 1; }
.clarity-refresh:hover { border-color: var(--accent-bright); color: var(--accent-bright); }
.clarity-refresh svg { width: 1.05em; height: 1.05em; }

/* Solid white heart in the "I ♥ Clear Business Processes" line */
.clarity-heart {
  width: 0.82em;
  height: 0.82em;
  display: inline-block;
  vertical-align: -0.06em;
  color: #fff;
  margin: 0 0.06em;
}

/* The cover canvas sits over the text */
.clarity-fog {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none; /* a touch starting here wipes, it doesn't scroll */
}
.clarity-fog:active { cursor: grabbing; }
/* Once revealed, let touches pass through so the page scrolls normally again */
.clarity-stage.is-clear .clarity-fog {
  touch-action: auto;
  pointer-events: none;
}

/* Swipe-gesture hint — visible before the first wipe, fades out once touched */
.clarity-gesture {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* wipes pass through to the canvas */
  color: #fff;
  opacity: 0.92;
  z-index: 2;
  transition: opacity 0.4s ease;
}
.js .clarity-gesture { display: flex; }
.clarity-gesture svg {
  width: clamp(46px, 12vw, 70px);
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.55));
  animation: clarity-swipe 1.7s ease-in-out infinite;
  transform-origin: center;
}
@keyframes clarity-swipe {
  0%, 100% { transform: translateX(9px) rotate(3deg); }
  50%      { transform: translateX(-9px) rotate(-5deg); }
}
.clarity-stage.is-touched .clarity-gesture,
.clarity-stage.is-clear .clarity-gesture { opacity: 0; }

/* No JS / reduced motion: no cover, text shown plainly */
.clarity-fog { display: none; }
.js .clarity-fog { display: block; }
@media (prefers-reduced-motion: reduce) {
  .clarity-gesture { display: none !important; }
}

/* ============ About ============ */

.about-grid {
  display: grid;
  gap: 2.5rem;
}

.lead {
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 1.25rem;
}

.about-text p + p { margin-top: 1rem; }
.about-text { color: var(--text-muted); }
.about-text .lead { color: var(--text); }

.about-side {
  display: grid;
  gap: 1.75rem;
  align-content: start;
}

/* Circular headshot with an accent ring that tints with the scroll theme.
   The wrapper carries a transparent overlay and the img ignores pointer
   events, so long-press/right-click save targets the shield, not the photo
   (a deterrent for casual saving — the file itself is still public). */
.portrait-wrap {
  position: relative;
  margin-inline: auto;
  width: fit-content;
}

.portrait-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: transparent;
  z-index: 1;
}

.portrait {
  width: clamp(160px, 50vw, 220px);
  height: auto; /* the height="480" attribute would otherwise win and stretch it */
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  border: 3px solid var(--accent);
  box-shadow:
    0 0 0 7px color-mix(in srgb, var(--accent) 22%, transparent),
    0 24px 48px -24px color-mix(in srgb, var(--accent) 65%, transparent);
}

.about-facts {
  list-style: none;
  display: grid;
  gap: 0.75rem;
  align-content: start;
  margin-top: 2.5rem;
}

.about-facts li {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.9rem 1.1rem;
  font-weight: 600;
}

.fact-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-bright);
  margin-bottom: 0.15rem;
}

@media (min-width: 48rem) {
  .about-grid { grid-template-columns: 1.6fr 1fr; }
  /* Facts become a centred 2×2 block below the text + photo */
  .about-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 44rem;
    margin-inline: auto;
    margin-top: 3.5rem;
  }
}

/* ============ Experience timeline ============ */

.timeline {
  list-style: none;
  position: relative;
  padding-left: 1.75rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.4rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 2px;
  background: linear-gradient(var(--accent), var(--border));
}

.timeline-item {
  position: relative;
  padding-bottom: 2rem;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.75rem;
  top: 0.45rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent);
}

.timeline-dates {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.timeline-role {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 0.2rem;
}

.timeline-company {
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.timeline-points {
  color: var(--text-muted);
  padding-left: 1.1rem;
  display: grid;
  gap: 0.4rem;
}

.timeline-logo {
  display: block;
  margin-top: 0.5rem;
  height: 24px;
  width: auto;
  opacity: 0.9;
}
.timeline-logo--tall { height: 32px; }

/* Tappable timeline entries */
.timeline-item {
  cursor: pointer;
}
.timeline-item:focus { outline: none; }

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Diagonal arrows signalling the card expands into a modal */
.timeline-expand {
  width: 1.2rem;
  height: 1.2rem;
  color: var(--accent-bright);
  flex-shrink: 0;
}

/* ============ Experience modal ============ */

.modal {
  position: fixed;
  inset: 0;
  /* Dynamic viewport height tracks the visible area as the iOS toolbar
     shows/hides, so the sheet always fills the real screen (fallback first). */
  height: 100svh;
  height: 100dvh;
  z-index: 200;
  display: flex;
  align-items: flex-end; /* bottom sheet on mobile */
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  /* Tall bottom sheet on mobile — % of the dvh-sized .modal, so it tracks the
     visible screen regardless of scroll / iOS toolbar state */
  max-height: calc(100% - max(1rem, env(safe-area-inset-top)));
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 1.5rem 1.5rem 0 0;
  padding: 1.75rem var(--pad-x) max(2rem, env(safe-area-inset-bottom));
  animation: sheet-up 0.3s cubic-bezier(0.32,0.72,0,1);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@media (min-width: 40rem) {
  .modal { align-items: center; justify-content: center; padding: 1.5rem; }
  .modal-panel {
    width: 100%;
    max-width: 36rem;
    max-height: 85dvh; /* centred card on desktop — keep margins */
    border-radius: 1.5rem;
    animation: modal-pop 0.25s cubic-bezier(0.34,1.56,0.64,1);
  }
  @keyframes modal-pop {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-panel { animation: none; }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  background: var(--border);
  border: none;
  border-radius: 50%;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--accent); color: #fff; }

.modal-dates {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-bright);
  margin-bottom: 0.25rem;
}

.modal-role {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.15rem;
}

.modal-company {
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.modal-body { color: var(--text-muted); line-height: 1.7; }
.modal-body p { margin-bottom: 1rem; }
.modal-body h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  margin: 1.25rem 0 0.5rem;
}
.modal-body ul { padding-left: 1.25rem; display: grid; gap: 0.4rem; }
.modal-body li { color: var(--text-muted); }

.modal-company-link {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.modal-company-link-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.modal-company-link a {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.9);
  border-radius: 0.5rem;
  transition: background 0.15s;
}
.modal-company-link a:hover { background: #fff; }
.modal-company-link img {
  display: block;
  height: 32px;
  width: auto;
}

.timeline-more {
  margin-top: 2.25rem;
  color: var(--text-muted);
}
.timeline-more a {
  color: var(--accent-bright);
  font-weight: 700;
  text-decoration: none;
}
.timeline-more a:hover { text-decoration: underline; }

/* ============ Skills chips ============ */

.chip-grid {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.chip-cert { border-color: var(--accent); }

/* Pills that open a description on tap */
.skills-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: -1.5rem 0 1.5rem;
}
.chip-interactive {
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.chip-interactive:hover,
.chip-interactive:focus-visible { border-color: var(--accent-bright); }
.chip-interactive:focus-visible { outline: none; }

/* ============ Events ============ */

.events-intro {
  color: var(--text-muted);
  margin: -1.25rem 0 2rem;
}

.event-list {
  list-style: none;
  display: grid;
  gap: 1rem;
}

.event-card {
  display: grid;
  gap: 0.2rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem 1.4rem;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, border-color 0.2s;
}
.event-card:hover { border-color: var(--accent-bright); }
.event-card:active { transform: scale(0.98); }

.event-date {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-bright);
}

.event-name {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.event-place {
  color: var(--text-muted);
  font-weight: 600;
}

@media (min-width: 40rem) {
  .event-list { grid-template-columns: 1fr 1fr; }
}

/* ============ Contact ============ */

.section-contact {
  text-align: center;
  padding-bottom: 3rem;
}

.contact-title {
  font-size: clamp(2.75rem, 11vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 1rem;
}

.contact-text {
  color: var(--text-muted);
  max-width: 44ch;
  margin: 0 auto 2.25rem;
  font-size: 1.1rem;
}

.section-contact .hero-actions { justify-content: center; }

/* LinkedIn QR connect code — white card so it scans reliably on the dark theme */
.qr-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2.5rem;
  padding: 1rem 1rem 0.8rem;
  background: #fff;
  border-radius: 1rem;
  text-decoration: none;
  transition: transform 0.15s;
}
.qr-card:active { transform: scale(0.97); }

.qr-card img {
  width: clamp(120px, 35vw, 160px);
  height: auto;
}

.qr-caption {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--bg);
}

/* ============ Footer ============ */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem var(--pad-x);
  padding-bottom: max(1.75rem, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-credit {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  opacity: 0.75;
}
.footer-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-credit a:hover { color: var(--accent-bright); }

/* ============ Scroll reveal ============
   JS adds .js to <html>, then .reveal-visible per element — so without JS
   nothing is ever hidden. */

.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* ============ 404 page ============ */

.error-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem var(--pad-x);
}

.error-code {
  font-size: clamp(5rem, 30vw, 12rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.error-page p {
  color: var(--text-muted);
  margin: 1rem 0 2rem;
  font-size: 1.15rem;
}
