/* =========================================================
   Sujal Luitel — Portfolio
   Pure HTML + CSS. Edit the colors below to re-theme the site.
   ========================================================= */

/* ---------- Theme colors ---------- */
:root {
  /* Dark theme (default) */
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c25;
  --border: #232937;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #34d399;
  --accent-strong: #10b981;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --on-accent: #062b1f;
  --danger: #f87171;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --grid-line: rgba(255, 255, 255, 0.035);

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --radius: 14px;
  --nav-h: 68px;
}

/* Light theme — activated by the toggle checkbox */
#theme-toggle:checked ~ .page {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5eb;
  --text: #111827;
  --muted: #566070;
  --accent: #059669;
  --accent-strong: #047857;
  --accent-soft: rgba(5, 150, 105, 0.1);
  --on-accent: #ffffff;
  --danger: #dc2626;
  --shadow: 0 10px 30px -14px rgba(15, 23, 42, 0.18);
  --grid-line: rgba(15, 23, 42, 0.045);
}
html:has(#theme-toggle:checked) { background: #f6f7f9; color-scheme: light; }

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
  background: #0b0d12;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body { font-family: var(--font-body); line-height: 1.65; }

.page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; letter-spacing: -0.02em; }

svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.mono { font-family: var(--font-mono); }
.accent { color: var(--accent); }

.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

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

::selection { background: var(--accent); color: var(--on-accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.8rem 1.4rem;
  border-radius: 10px;
  font-weight: 600; font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 8px 24px -10px var(--accent); }
#theme-toggle:checked ~ .page .btn-primary:hover { color: #fff; }

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

.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--nav-h); }

.logo { display: inline-flex; align-items: center; gap: 0.6rem; font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
.logo-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600;
}

.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  padding: 0.45rem 0.85rem; border-radius: 8px;
  font-size: 0.92rem; font-weight: 500; color: var(--muted);
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }

.nav-actions { display: flex; gap: 0.5rem; }

/* Theme toggle icons */
.theme-btn .icon-moon { display: none; }
#theme-toggle:checked ~ .page .theme-btn .icon-sun { display: none; }
#theme-toggle:checked ~ .page .theme-btn .icon-moon { display: block; }
#theme-toggle:focus-visible ~ .page .theme-btn { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  padding: clamp(3.5rem, 8vw, 6.5rem) 0 clamp(3.5rem, 7vw, 5.5rem);
}
/* Subtle grid background, faded at the bottom */
.hero::before {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
.hero-grid { display: grid; grid-template-columns: 1.25fr 1fr; align-items: center; gap: clamp(2rem, 5vw, 4.5rem); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
  font-size: 0.82rem; color: var(--muted);
  margin-bottom: 1.4rem;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.hero h1 { font-size: clamp(2.4rem, 5.5vw, 3.9rem); font-weight: 700; margin-bottom: 0.9rem; }

/* Rotating titles (CSS-only "typing" effect) */
.hero-role {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--text);
  margin-bottom: 1.4rem;
}
.hero-role > .mono { color: var(--accent); }
.rotator { display: inline-block; height: 1.6em; line-height: 1.6em; overflow: hidden; }
.rotator-track { display: flex; flex-direction: column; animation: rotate-titles 9s cubic-bezier(0.7, 0, 0.3, 1) infinite; }
.rotator-track span { height: 1.6em; white-space: nowrap; }
@keyframes rotate-titles {
  0%, 28%   { transform: translateY(0); }
  33%, 61%  { transform: translateY(-1.6em); }
  66%, 94%  { transform: translateY(-3.2em); }
  100%      { transform: translateY(-4.8em); }
}
.caret { width: 0.6em; height: 1.15em; background: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.hero-intro { color: var(--muted); font-size: 1.05rem; max-width: 34rem; margin-bottom: 2rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-bottom: 2rem; }
.socials { display: flex; gap: 0.6rem; }

/* Photo */
.hero-photo { position: relative; isolation: isolate; justify-self: center; width: min(100%, 380px); }
.photo-frame {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--surface-2);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; transition: transform 0.6s ease; }
.hero-photo:hover .photo-frame img { transform: scale(1.03); }
.hero-photo::before {
  content: "";
  position: absolute; inset: 14px -14px -14px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 22px;
  opacity: 0.55;
  z-index: -1;
  transition: inset 0.3s ease;
}
.hero-photo:hover::before { inset: 8px -8px -8px 8px; }
.photo-tag {
  position: absolute; left: -14px; bottom: 26px;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-size: 0.78rem; color: var(--text);
  box-shadow: var(--shadow);
}
.photo-tag svg { width: 15px; height: 15px; color: var(--accent); }

/* ---------- Sections ---------- */
.section { padding: clamp(4rem, 8vw, 6rem) 0; }
.section + .section { border-top: 1px solid var(--border); }

.section-head { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 2.5rem; }
.section-head h2 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); }
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--border); align-self: center; max-width: 260px; margin-left: 0.5rem; }
.section-num { color: var(--accent); font-size: 1rem; }
.section-sub { color: var(--muted); margin: -1.5rem 0 2.25rem; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.about-text p { color: var(--muted); font-size: 1.04rem; margin-bottom: 1.1rem; }
.about-text strong { color: var(--text); font-weight: 600; }

.focus-list { display: grid; gap: 0.85rem; }
.focus-list li {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.focus-list li:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); transform: translateX(4px); }
.focus-icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.85rem; font-weight: 500;
}
.focus-list h3 { font-size: 1rem; margin-bottom: 0.15rem; }
.focus-list p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.skill-card {
  padding: 1.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.skill-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow); }
.skill-head { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1.25rem; }
.skill-head h3 { font-size: 1.15rem; }
.skill-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tags li {
  padding: 0.42rem 0.85rem;
  font-size: 0.86rem; font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.tags li:hover { color: var(--accent); border-color: var(--accent); }
.tags-sm li { font-family: var(--font-mono); font-size: 0.74rem; padding: 0.3rem 0.6rem; color: var(--muted); }

/* ---------- Projects ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1.5rem; }
.project-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.project-card:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow); }

.project-thumb { aspect-ratio: 16 / 9; border-bottom: 1px solid var(--border); background: var(--surface-2); overflow: hidden; }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.project-card:hover .project-thumb img { transform: scale(1.04); }

.thumb-code { display: flex; align-items: center; padding: 1.25rem 1.5rem; position: relative; }
.thumb-code::before {
  content: ""; position: absolute; top: 12px; left: 14px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #f87171; box-shadow: 15px 0 0 #fbbf24, 30px 0 0 #34d399;
}
.thumb-code pre { font-size: clamp(0.72rem, 1.6vw, 0.82rem); line-height: 1.7; color: var(--text); margin-top: 0.75rem; white-space: pre; overflow: hidden; }
.c-k { color: #60a5fa; }
.c-a { color: #c084fc; }
.c-s { color: var(--accent); }

.thumb-empty { display: grid; place-items: center; color: var(--muted); }
.thumb-empty svg { width: 40px; height: 40px; stroke-width: 1.5; }
.project-placeholder { border-style: dashed; }

.project-body { display: flex; flex-direction: column; gap: 0.85rem; padding: 1.4rem; flex: 1; }
.project-body h3 { font-size: 1.15rem; }
.project-body p { color: var(--muted); font-size: 0.93rem; }
.project-links { display: flex; gap: 0.6rem; margin-top: auto; padding-top: 0.4rem; }

/* ---------- Education ---------- */
.timeline { position: relative; padding-left: 2rem; max-width: 760px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; }
.timeline-dot {
  position: absolute; left: -2rem; top: 1.6rem;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.edu-card {
  padding: 1.6rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.25s ease;
}
.edu-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.edu-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.edu-top h3 { font-size: 1.25rem; }
.badge {
  padding: 0.3rem 0.75rem; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.75rem;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.edu-school { font-weight: 600; margin-bottom: 0.3rem; }
.edu-meta { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.93rem; }
.edu-meta svg { width: 16px; height: 16px; color: var(--accent); }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: clamp(2rem, 5vw, 3.5rem); align-items: start; }
.contact-lead { color: var(--muted); font-size: 1.04rem; margin-bottom: 1.75rem; }

.info-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, transform 0.2s ease;
  word-break: break-word;
}
a.info-item:hover { border-color: var(--accent); transform: translateX(4px); }
.info-item small { display: block; font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.info-item > span:last-child { font-weight: 500; }
.info-icon { flex-shrink: 0; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }

.contact-form {
  padding: clamp(1.4rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.field label { font-size: 0.88rem; font-weight: 500; }
.field input,
.field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font: inherit; font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field textarea { resize: vertical; min-height: 130px; }
.field input::placeholder,
.field textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field input:focus,
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Validation: show errors only after the user has interacted with a field */
.field-error { display: none; font-size: 0.8rem; color: var(--danger); }
.field input:user-invalid,
.field textarea:user-invalid { border-color: var(--danger); }
.field input:user-invalid:focus,
.field textarea:user-invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.field input:user-invalid ~ .field-error,
.field textarea:user-invalid ~ .field-error { display: block; }

.honeypot { display: none !important; }
.form-note { margin-top: 0.85rem; text-align: center; font-size: 0.8rem; color: var(--muted); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); padding-top: 3rem; }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 2rem; padding-bottom: 2rem; }
.footer-role { color: var(--muted); font-size: 0.92rem; margin: 0.6rem 0 0.3rem; }
.footer-mail { font-size: 0.92rem; color: var(--accent); }
.footer-mail:hover { text-decoration: underline; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; max-width: 380px; }
.footer-links a { color: var(--muted); font-size: 0.92rem; transition: color 0.2s ease; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem;
  padding: 1.25rem 0 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem; color: var(--muted);
}
.back-top { font-size: 0.8rem; transition: color 0.2s ease; }
.back-top:hover { color: var(--accent); }

/* ---------- Scroll reveal (modern browsers only, progressive) ---------- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal .container {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 30%;
    }
  }
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hero entrance */
@media (prefers-reduced-motion: no-preference) {
  .hero-text > * { animation: fade-up 0.7s ease both; }
  .hero-text > *:nth-child(2) { animation-delay: 0.08s; }
  .hero-text > *:nth-child(3) { animation-delay: 0.16s; }
  .hero-text > *:nth-child(4) { animation-delay: 0.24s; }
  .hero-text > *:nth-child(5) { animation-delay: 0.32s; }
  .hero-text > *:nth-child(6) { animation-delay: 0.4s; }
  .hero-photo { animation: fade-up 0.9s 0.2s ease both; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero-photo { order: -1; width: min(72%, 300px); }
  .hero-text { display: flex; flex-direction: column; align-items: center; }
  .hero-role { justify-content: center; }
  .hero-intro { margin-inline: auto; }
  .about-grid,
  .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --nav-h: 108px; }
  .nav-inner { flex-wrap: wrap; padding-top: 0.7rem; gap: 0.5rem; }
  /* Nav links become a horizontally scrollable row on small screens */
  .nav-links {
    order: 3; width: 100%;
    overflow-x: auto; scrollbar-width: none;
    padding-bottom: 0.55rem;
    margin-inline: -0.25rem;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { flex-shrink: 0; padding: 0.4rem 0.75rem; font-size: 0.88rem; }
  .skills-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 480px) {
  .container { width: calc(100% - 2rem); }
  .hero-cta { width: 100%; flex-direction: column; }
  .hero-cta .btn { width: 100%; }
  .photo-tag { left: 50%; transform: translateX(-50%); bottom: -16px; white-space: nowrap; }
  .hero-photo::before { inset: 10px -10px -10px 10px; }
  .section-head::after { display: none; }
  .footer-grid { flex-direction: column; }
}
