/* ===== Dark theme colours (default) ===== */
:root {
  --bg: #0f172a;          /* page background */
  --surface: #1e293b;     /* cards */
  --text: #e2e8f0;        /* main text */
  --muted: #94a3b8;       /* secondary text */
  --accent: #38bdf8;      /* highlight color */
  --hero-end: #1e3a5f;    /* end colour of header gradient */
  --shadow: rgba(0, 0, 0, 0.4);
  --correct: #22c55e;     /* quiz: right answer */
  --wrong: #ef4444;       /* quiz: wrong answer */
  --radius: 12px;         /* rounded corners */
  --max-width: 960px;     /* content width */
}

/* ===== Light theme: script.js sets data-theme="light" on <html> ===== */
[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --accent: #0284c7;
  --hero-end: #dbeafe;
  --shadow: rgba(15, 23, 42, 0.12);
  --correct: #16a34a;
  --wrong: #dc2626;
}

/* ===== Reset: consistent sizing and no default margins ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Smooth scrolling when clicking nav links */
html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;   /* smooth theme switch */
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ===== Header & navigation ===== */
.site-header {
  background: linear-gradient(135deg, var(--bg) 0%, var(--hero-end) 100%);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;               /* logo left, links right */
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--text);
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--muted);
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--accent);
}

/* Round sun/moon button */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.3s;
}

.theme-toggle:hover {
  transform: rotate(20deg);
}

/* Hero area with name and tagline */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 6rem 1.5rem 7rem;
  text-align: center;
}

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

.hero h1 {
  font-size: clamp(2.5rem, 8vw, 4.5rem);  /* scales with screen width */
  line-height: 1.1;
  margin: 0.5rem 0;
}

.tagline {
  color: var(--muted);
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  border: 2px solid var(--accent);
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.btn:hover {
  transform: translateY(-2px);   /* small lift on hover */
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
}

/* Visible keyboard focus for all interactive elements */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ===== Sections ===== */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

.section h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

/* Short accent line under each section heading */
.section h2::after {
  content: "";
  display: block;
  width: 50px;
  height: 4px;
  margin-top: 0.5rem;
  background: var(--accent);
  border-radius: 2px;
}

.section p {
  color: var(--muted);
  max-width: 65ch;   /* comfortable reading width */
}

.section strong {
  color: var(--text);
}

/* Interest tags in About Me */
.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.tags li {
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 999px;   /* pill shape */
  font-size: 0.9rem;
}

/* ===== Skills grid ===== */
.skills-grid {
  list-style: none;
  display: grid;
  /* auto-fit makes as many columns as fit, each at least 120px */
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.skill-card {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 8px var(--shadow);
}

/* ===== Projects grid ===== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.project-card {
  background: var(--surface);
  padding: 1.75rem;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px var(--shadow);
}

.project-card a {
  margin-top: auto;   /* pushes link to the bottom of the card */
  font-weight: 600;
}

/* ===== Quiz ===== */
.quiz-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 1.5rem;
  max-width: 640px;
  box-shadow: 0 2px 8px var(--shadow);
}

.quiz-progress {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quiz-question {
  font-size: 1.3rem;
  margin: 0.5rem 0 1.25rem;
}

/* Answer buttons stacked in a column */
.quiz-options {
  display: grid;
  gap: 0.75rem;
}

.quiz-option {
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--muted);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
}

.quiz-option:disabled {
  cursor: default;
}

/* Colours added by script.js after an answer is picked */
.quiz-option.correct {
  border-color: var(--correct);
  background: color-mix(in srgb, var(--correct) 20%, transparent);
}

.quiz-option.wrong {
  border-color: var(--wrong);
  background: color-mix(in srgb, var(--wrong) 20%, transparent);
}

.quiz-feedback {
  min-height: 1.6em;   /* reserves space so the button doesn't jump */
  margin: 1rem 0;
  font-weight: 600;
}

.quiz-result {
  text-align: center;
}

.quiz-result p {
  margin: 0 auto 1rem;
}

.quiz-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent) !important;
}

/* ===== Contact ===== */
.contact-links {
  font-style: normal;  /* <address> is italic by default */
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  border-top: 1px solid var(--surface);
  font-size: 0.9rem;
}

/* ===== Responsive: tweaks for phones (screens up to 600px) ===== */
@media (max-width: 600px) {
  .nav {
    flex-direction: column;   /* stack logo above links */
    gap: 0.75rem;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  .hero {
    padding: 4rem 1.25rem 5rem;
  }

  .section {
    padding: 3rem 1.25rem;
  }

  .quiz-card {
    padding: 1.25rem;
  }

  .contact-links .btn,
  .quiz-card .btn {
    width: 100%;          /* full-width buttons on mobile */
    text-align: center;
  }
}

/* ===== Back to top button ===== */
#back-to-top {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1000;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;          /* out of Tab order until shown */
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

#back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

#back-to-top:hover { filter: brightness(1.1); }

#back-to-top:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  #back-to-top { transition: none; }
}

@media print {
  #back-to-top { display: none; }
}
