/* ============================================================
   Nishantha Jayawardhana — Portfolio
   Modern dark theme, system fonts only (CSP-friendly, no CDNs)
   ============================================================ */

/* Palette adapted from the Blocksy theme demo the owner likes:
   blue #2872fa / #1559ed, slate #1d2b35 / #344048, light #e1e8ed–#FAFBFC.
   Dark is the default; the footer toggle switches to light (persisted). */
:root {
  color-scheme: dark;
  --bg: #131e28;
  --bg-soft: #1d2b35;
  --card: #1d2b35;
  --border: #344048;
  --text: #e9eff4;
  --text-dim: #9fb0bd;
  --accent: #6ba0ff;
  --accent-strong: #2872fa;
  --btn-text: #ffffff;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FAFBFC;
  --bg-soft: #f2f5f7;
  --card: #ffffff;
  --border: #e1e8ed;
  --text: #1d2b35;
  --text-dim: #566470;
  --accent: #2872fa;
  --accent-strong: #1559ed;
  --btn-text: #ffffff;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container { width: min(1080px, 92%); margin-inline: auto; }
.accent { color: var(--accent); }

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--btn-text);
  padding: 0.5rem 1rem; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand {
  font-family: var(--mono); font-size: 1.35rem; font-weight: 700;
  color: var(--text); text-decoration: none; letter-spacing: 0.02em;
}
.nav-menu {
  display: flex; gap: 1.75rem; list-style: none; align-items: center;
}
.nav-menu a {
  color: var(--text-dim); text-decoration: none; font-size: 0.95rem;
  transition: color 0.2s;
}
.nav-menu a:hover, .nav-menu a:focus-visible { color: var(--accent); }
.nav-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 0.7rem 1.5rem; border-radius: 10px;
  background: var(--accent); color: var(--btn-text) !important; font-weight: 600;
  text-decoration: none; border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}
.btn:hover, .btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-strong);
}
.btn-ghost {
  background: transparent; color: var(--accent) !important;
  border-color: var(--accent);
}
.btn-ghost:hover, .btn-ghost:focus-visible {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: none;
}
.btn-small { padding: 0.45rem 1.1rem; font-size: 0.9rem; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  min-height: calc(100svh - 64px);
  display: grid; align-items: center;
}
.hero-glow {
  position: absolute; inset: auto -20% -40% -20%; height: 70%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--accent) 18%, transparent), transparent 65%);
  pointer-events: none;
}
.hero-kicker { font-family: var(--mono); color: var(--accent); margin-bottom: 0.75rem; }
.hero-title {
  font-size: clamp(2.6rem, 7vw, 4.8rem); line-height: 1.05;
  letter-spacing: -0.02em; font-weight: 800; margin-bottom: 1.25rem;
}
.hero-sub {
  max-width: 46ch; color: var(--text-dim);
  font-size: clamp(1rem, 2vw, 1.2rem); margin-bottom: 2.25rem;
}
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---------- Hero motion graphic ---------- */
.hero-inner {
  display: grid; grid-template-columns: 1.15fr 0.85fr;
  gap: 2.5rem; align-items: center;
}
.hero-visual {
  position: relative; width: min(400px, 80vw); aspect-ratio: 1;
  margin-inline: auto;
}
/* Rings rotate very slowly — calm, ambient motion */
.ring-dashed {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 30%, transparent);
  animation: spin 300s linear infinite reverse;
}
.orbit {
  position: absolute; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  animation: spin 180s linear infinite;
}
.orbit-1 { inset: 9%; }
.orbit-2 { inset: 23%; animation-duration: 140s; animation-direction: reverse; }
.sat {
  position: absolute; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 70%, transparent);
}
.sat-a { top: -7px; left: calc(50% - 6px); }
.sat-b { bottom: 18%; left: -4px; }
.core {
  position: absolute; inset: 35%; display: grid; place-items: center;
  border-radius: 50%; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.core::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--accent);
  animation: ping 7s ease-out infinite;
}
.chip {
  position: absolute; z-index: 2;
  font-family: var(--mono); font-size: 0.72rem; white-space: nowrap;
  padding: 0.32rem 0.75rem; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-dim);
  box-shadow: 0 8px 22px color-mix(in srgb, #000 22%, transparent);
  animation: floaty 16s ease-in-out infinite;
}
.chip-1 { top: 7%; left: 0; }
.chip-2 { top: 24%; right: -3%; animation-delay: -1.6s; }
.chip-3 { bottom: 20%; left: -4%; animation-delay: -3.1s; }
.chip-4 { bottom: 4%; right: 9%; animation-delay: -4.5s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-11px); }
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.7; }
  80%, 100% { transform: scale(1.7); opacity: 0; }
}

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-visual { display: none; }
}

/* ---------- Sections ---------- */
.section { padding: 5.5rem 0; }
.section:nth-of-type(even) { background: var(--bg-soft); }
.section-title {
  font-size: clamp(1.6rem, 3.5vw, 2.1rem); margin-bottom: 2.5rem;
  letter-spacing: -0.01em;
}
.section-title .accent { font-family: var(--mono); font-size: 0.8em; margin-right: 0.4rem; }

/* ---------- About ---------- */
.about-grid { display: grid; gap: 1.25rem; max-width: 70ch; color: var(--text-dim); }

/* ---------- Cards / Skills ---------- */
.skills-grid, .projects-grid {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.6rem;
  transition: transform 0.2s, border-color 0.2s;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); }
.card h3 { margin-bottom: 0.9rem; font-size: 1.1rem; }
.card p { color: var(--text-dim); font-size: 0.95rem; margin-bottom: 1rem; }

.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-list li {
  font-family: var(--mono); font-size: 0.78rem; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 0.25rem 0.7rem; border-radius: 999px;
}

/* ---------- Timeline ---------- */
.timeline { list-style: none; position: relative; padding-left: 1.75rem; max-width: 46rem; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 2.5rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.75rem; top: 8px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.timeline-meta { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); margin-bottom: 0.3rem; }
.timeline-item h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.timeline-item .at { color: var(--text-dim); font-weight: 500; }
.timeline-item p { color: var(--text-dim); font-size: 0.95rem; max-width: 60ch; }

/* ---------- Contact / Footer ---------- */
.section-contact { text-align: center; }
.contact-lead { color: var(--text-dim); max-width: 50ch; margin: 0 auto 2rem; }
.contact-actions { justify-content: center; }

.project h3 a { color: inherit; text-decoration: none; }
.project h3 a:hover, .project h3 a:focus-visible { color: var(--accent); }
.site-footer {
  border-top: 1px solid var(--border); padding: 1.75rem 0;
  color: var(--text-dim); font-size: 0.85rem;
}
.footer-inner {
  display: flex; justify-content: center; align-items: center; gap: 0.9rem;
}
.theme-toggle {
  display: grid; place-items: center; padding: 7px;
  background: none; border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-dim); cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover, .theme-toggle:focus-visible { color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .orbit, .ring-dashed, .chip, .core::after { animation: none; }
}

/* ---------- Error page ---------- */
.error-page { text-align: center; min-height: 100svh; }
.error-page .hero-sub { margin-inline: auto; }

/* ---------- Mobile nav ---------- */
@media (max-width: 720px) {
  .nav-toggle {
    display: grid; gap: 5px; background: none; border: 0; cursor: pointer; padding: 8px;
  }
  .nav-toggle span {
    width: 24px; height: 2px; background: var(--text); border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .nav-menu {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 0.5rem 0 1rem;
    background: var(--bg); border-bottom: 1px solid var(--border);
    display: none;
  }
  .nav-menu.open { display: flex; }
  .nav-menu li { width: 100%; text-align: center; }
  .nav-menu a { display: inline-block; padding: 0.7rem 0; }
}
