/* =========================================================
   Marikaimu Chris Ardoña — Portfolio
   Hand-coded. No frameworks.
   ========================================================= */

:root {
  --bg:        #ffffff;
  --bg-alt:    #f4f4f1;
  --ink:       #17171a;
  --muted:     #57585d;
  --faint:     #8c8d92;
  --accent:    #18181c;
  --accent-2:  #3c3d44;
  --on-accent: #ffffff;
  --rule:      #e6e6e1;
  --card:      #ffffff;
  --header-bg: rgba(255,255,255,.86);
  --chip-bg:   #f1f1ed;
  --overlay-btn: rgba(255,255,255,.92);
  --panel:     #17171a;
  --panel-ink: #f3f3f1;
  --shadow:    0 1px 2px rgba(20,20,24,.04), 0 4px 14px rgba(20,20,24,.05);
  --dot:       rgba(23,23,26,.18);
  --radius:    9px;
  --maxw:      1080px;
  --font:      "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
}

:root[data-theme="dark"] {
  --bg:        #0f0f11;
  --bg-alt:    #17171a;
  --ink:       #f2f2f0;
  --muted:     #adaeb3;
  --faint:     #7d7e84;
  --accent:    #ededee;
  --accent-2:  #b9babf;
  --on-accent: #15151a;
  --rule:      #2a2a2e;
  --card:      #18181b;
  --header-bg: rgba(15,15,17,.84);
  --chip-bg:   #222226;
  --overlay-btn: rgba(24,24,27,.92);
  --panel:     #08080a;
  --panel-ink: #f3f3f1;
  --shadow:    0 1px 3px rgba(0,0,0,.5), 0 10px 28px rgba(0,0,0,.45);
  --dot:       rgba(242,242,240,.16);
}

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

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body { transition: background .25s ease, color .25s ease; }

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

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

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 24px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(156,74,48,.22); }
.btn-ghost { color: var(--accent); border-color: var(--rule); background: var(--card); }
.btn-ghost:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.nav-bar { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--ink); }
.brand-dot { color: var(--accent-2); }

.nav-menu { list-style: none; display: flex; gap: 6px; align-items: center; }
.nav-menu a {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: color .15s ease, background .15s ease;
}
.nav-menu a:hover { color: var(--ink); background: var(--bg-alt); }
.nav-menu a.nav-cta { color: var(--on-accent); background: var(--accent); }
.nav-menu a.nav-cta:hover { background: var(--accent-2); }

.nav-cluster { display: flex; align-items: center; gap: 8px; }

.nav-overlay { display: none; }

.nav-toggle { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 42px; height: 42px; align-items: center; background: none; border: 0; cursor: pointer; }
.nav-toggle span { width: 24px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .25s ease, opacity .25s ease; }
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: none; border: 1px solid var(--rule); color: var(--ink);
  cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.theme-toggle:hover { background: var(--bg-alt); border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Hero ---------- */
@property --mx { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
@property --my { syntax: "<percentage>"; inherits: true; initial-value: 30%; }

.hero {
  position: relative;
  padding: 104px 0 88px;
  background: var(--bg);
  overflow: hidden;
}
.hero-inner { position: relative; z-index: 1; }

/* Interactive dot grid revealed by a soft spotlight that follows the cursor,
   applied to the hero and every section (behind content, pointer-safe). */
.hero, .section { position: relative; isolation: isolate; }
.hero::before, .section::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle at center, var(--dot) 1.1px, transparent 1.6px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(300px circle at var(--mx) var(--my), #000 0%, rgba(0,0,0,.4) 45%, transparent 72%);
  mask-image: radial-gradient(300px circle at var(--mx) var(--my), #000 0%, rgba(0,0,0,.4) 45%, transparent 72%);
  transition: --mx .28s ease-out, --my .28s ease-out;
}
.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 14px;
}
.hero-title { font-size: clamp(38px, 6vw, 62px); line-height: 1.04; letter-spacing: -1.2px; font-weight: 800; }
.hero-lead { margin-top: 22px; max-width: 640px; font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); }
.hero-actions { margin-top: 32px; display: flex; gap: 14px; flex-wrap: wrap; }

.hero-stats {
  list-style: none;
  display: flex;
  gap: 40px;
  margin-top: 54px;
  flex-wrap: wrap;
  border-top: 1px solid var(--rule);
  padding-top: 26px;
}
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 24px; font-weight: 800; color: var(--ink); }
.hero-stats span { font-size: 14px; color: var(--faint); }

/* ---------- Sections ---------- */
.section { padding: 84px 0; }
.section-alt { background: var(--bg-alt); }
.section-head { margin-bottom: 44px; }
.section-index { display: inline-block; font-size: 14px; font-weight: 700; color: var(--accent-2); letter-spacing: 1px; margin-bottom: 6px; }
.section-head h2 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.6px; font-weight: 800; }
.section-sub { margin-top: 8px; color: var(--muted); font-size: 17px; }

/* ---------- About ---------- */
.about-panel {
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 40px 44px;
}
.about-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 48px; }
.about-lead { font-family: var(--font-serif); font-size: clamp(21px, 2.7vw, 28px); font-weight: 500; line-height: 1.3; letter-spacing: -0.01em; color: var(--ink); }
.about-body p { color: var(--muted); }
.about-body p + p { margin-top: 16px; }

/* ---------- Projects (card grid) ---------- */
/* Work section spans the full width (no max-width), with scaling gutters */
#work .container { max-width: none; padding-left: clamp(24px, 5vw, 72px); padding-right: clamp(24px, 5vw, 72px); }
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.project-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.project-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(31,28,23,.09); }
.project-banner {
  position: relative;
  aspect-ratio: 668 / 232;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
}
.project-banner img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.project-banner--top img { object-position: top; }
.project-banner-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 32px; font-weight: 800; letter-spacing: 1.5px; opacity: .95;
}
.project-card-body { padding: 16px 18px; display: flex; flex-direction: column; flex: 1; }
.project-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.project-tag-role { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; color: var(--accent); background: var(--chip-bg); padding: 3px 8px; border-radius: 4px; }
.project-date { font-size: 12.5px; color: var(--faint); }
.project-title { font-size: 17px; font-weight: 700; letter-spacing: -.3px; line-height: 1.25; }
.project-blurb { margin-top: 6px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.project-tech { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.project-tech li { font-size: 11.5px; font-weight: 500; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 2px 8px; }
.project-view {
  margin-top: auto; padding-top: 14px;
  background: none; border: 0; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 13.5px;
  color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
}
.project-view span { transition: transform .18s ease; }
.project-card:hover .project-view span,
.project-view:hover span { transform: translateX(4px); }

/* ---------- Featured personal-project card ---------- */
.featured-card {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.featured-card + .featured-card { margin-top: 28px; }
.featured-media { position: relative; border-right: 1px solid var(--rule); overflow: hidden; }
.featured-media img { width: 100%; height: 100%; object-fit: cover; object-position: left top; display: block; }
.featured-body { padding: 30px 34px; display: flex; flex-direction: column; }
.featured-body .project-title { font-size: 24px; margin-top: 2px; }
.featured-body .project-blurb { font-size: 15px; margin-top: 12px; }
.featured-body .project-tech { margin-top: 18px; }
.featured-body .project-view { padding-top: 22px; }
@media (max-width: 760px) {
  .featured-card { grid-template-columns: 1fr; }
  .featured-media { border-right: 0; border-bottom: 1px solid var(--rule); aspect-ratio: 16 / 10; }
  .featured-body { padding: 22px 20px; }
  .featured-body .project-title { font-size: 21px; }
}

/* ---------- Project detail dialog ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 20px;
  background: rgba(16,32,43,.55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  overflow-y: auto;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  position: relative; width: 100%; max-width: 760px;
  background: var(--card); border-radius: 12px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(16,32,43,.32);
  animation: dlg-in .25s ease;
}
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.dialog-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: var(--overlay-btn); color: var(--ink);
  font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(16,32,43,.2);
  transition: background .15s ease, transform .15s ease;
}
.dialog-close:hover { background: var(--card); transform: scale(1.05); }
.dialog-figure { margin: 0; background: var(--bg-alt); border-bottom: 1px solid var(--rule); }
.dialog-figure img { width: 100%; display: block; max-height: 440px; object-fit: cover; object-position: center; }
.dialog-figure--grid { display: grid; grid-template-columns: 1fr 1fr; }
.dialog-figure--grid img { height: auto; max-height: none; object-fit: contain; }
/* Image carousel inside dialogs */
.gallery { position: relative; background: var(--bg-alt); border-bottom: 1px solid var(--rule); }
.gallery-viewport { overflow: hidden; aspect-ratio: 16 / 10; }
.gallery-track { display: flex; height: 100%; transition: transform .35s ease; }
.gallery-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(16,32,43,.55); color: #fff; font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s ease;
}
.gallery-nav:hover { background: rgba(16,32,43,.82); }
.gallery-prev { left: 12px; }
.gallery-next { right: 12px; }
.gallery-dots { position: absolute; bottom: 12px; left: 0; right: 0; z-index: 2; display: flex; gap: 7px; justify-content: center; }
.gallery-dots button {
  width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.5); cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.gallery-dots button.active { background: #fff; transform: scale(1.25); }
.dialog-content { padding: 26px 30px 32px; }
.dialog.no-figure .dialog-content { padding-top: 54px; }
.dialog-content h3 { font-size: 25px; font-weight: 800; letter-spacing: -.4px; line-height: 1.2; margin-top: 4px; }
.dialog-content p { margin-top: 14px; color: var(--muted); font-size: 16px; }
.dialog-content .project-tech { margin-top: 18px; }
.dialog-content .btn { margin-top: 22px; gap: 9px; }
.dialog-content .btn span { display: inline-block; transition: transform .18s ease; }
.dialog-content .btn:hover span { transform: translateX(5px); }
.dialog-creds { margin-top: 20px; padding: 13px 16px; border: 1px dashed var(--rule); border-radius: 8px; background: var(--card); display: flex; flex-direction: column; gap: 3px; }
.dialog-creds strong { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); margin-bottom: 4px; }
.dialog-creds span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; color: var(--ink); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.dialog-actions .btn { margin-top: 22px; }
body.dialog-open { overflow: hidden; }

/* ---------- AI Tooling (card grid) ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 26px 26px 28px;
  box-shadow: var(--shadow);
}
.tool-card h3 {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.2px;
}
.tool-what { margin-top: 12px; color: var(--ink); font-size: 15px; }
.tool-help { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.tool-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .9px; font-weight: 700; color: var(--faint); margin-bottom: 6px; }
.tool-help p { color: var(--muted); font-size: 14.5px; }

/* ---------- Skills (definition list) ---------- */
.skills-list { border-top: 1px solid var(--rule); }
.skill-row {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 36px;
  align-items: baseline;
  padding: 22px 4px;
  border-bottom: 1px solid var(--rule);
}
.skill-row dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: var(--faint);
  padding-top: 4px;
}
.skill-row dd {
  font-family: var(--font-serif);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.55;
  color: var(--ink);
  font-weight: 400;
}
.skill-note { font-family: var(--font); font-size: 13px; color: var(--faint); }

/* ---------- Experience ---------- */
.xp-list { border-top: 1px solid var(--rule); }
.xp-row {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 36px;
  padding: 30px 4px;
  border-bottom: 1px solid var(--rule);
}
.xp-period {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: var(--faint);
  padding-top: 7px;
  white-space: nowrap;
}
.xp-role { font-size: 22px; }
.xp-company { font-weight: 600; color: var(--accent); margin-top: 3px; font-size: 15px; }
.xp-desc { margin-top: 13px; color: var(--muted); font-size: 16px; max-width: 64ch; }

/* ---------- Contact ---------- */
.section-contact {
  background: var(--bg-alt);
  border-top: 1px solid var(--rule);
}
.contact-inner { max-width: var(--maxw); }
.contact-eyebrow { text-transform: uppercase; letter-spacing: 2.5px; font-size: 13px; font-weight: 700; color: var(--accent-2); }
.section-contact h2 { font-size: clamp(30px, 5vw, 48px); letter-spacing: -.01em; margin-top: 12px; }
.contact-lead { margin-top: 16px; color: var(--muted); font-size: 18px; max-width: 54ch; }
.contact-email {
  display: inline-block;
  margin-top: 32px;
  font-family: var(--font-serif);
  font-size: clamp(22px, 3.6vw, 34px);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  border-bottom: 2px solid var(--rule);
  padding-bottom: 5px;
  transition: border-color .2s ease, color .2s ease;
}
.contact-email:hover { border-color: var(--accent); color: var(--accent); }
.contact-links { list-style: none; display: flex; flex-wrap: wrap; gap: 26px; margin-top: 30px; }
.contact-links a { font-size: 15px; font-weight: 600; color: var(--muted); }
.contact-links a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--faint); font-size: 14px; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Editorial serif headings ---------- */
.hero-title,
.section-head h2,
.section-contact h2,
.project-title,
.dialog-content h3,
.xp-role {
  font-family: var(--font-serif);
  font-weight: 600;
  font-optical-sizing: auto;
  letter-spacing: -0.012em;
}
.hero-title { letter-spacing: -0.02em; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .projects { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; gap: 22px; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Collapse the nav to a toggle menu before the links crowd the toggle */
@media (max-width: 820px) {
  .nav-toggle { display: flex; }

  .nav-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 16px;
    left: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 22px 48px rgba(16,32,43,.24);
    z-index: 60;
    /* closed state (kept in DOM so it can animate) */
    display: flex;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(.98);
    transform-origin: top right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
  }
  .nav-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
  }

  .nav-menu li { width: 100%; }
  .nav-menu a {
    display: block;
    padding: 13px 16px;
    border-radius: 11px;
    font-size: 16px;
    font-weight: 500;
    color: var(--ink);
    transition: background .15s ease, color .15s ease;
  }
  .nav-menu a:hover,
  .nav-menu a:active { background: var(--bg-alt); color: var(--accent); }
  .nav-menu li:last-child { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--rule); }
  .nav-menu a.nav-cta {
    text-align: center;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
  }
  .nav-menu a.nav-cta:hover { background: var(--accent-2); color: var(--on-accent); }

  .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(8,14,20,.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s;
  }
  .nav-overlay.show { opacity: 1; visibility: visible; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .projects { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
  .skill-row { grid-template-columns: 1fr; gap: 6px; padding: 18px 4px; }
  .xp-row { grid-template-columns: 1fr; gap: 8px; padding: 24px 4px; }
  .dialog-figure--grid { grid-template-columns: 1fr; }
  .hero { padding: 64px 0 56px; }
  .hero-stats { gap: 26px; }
  .about-panel { padding: 28px 22px; }
  .footer-inner { justify-content: center; text-align: center; }
}

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