/* ==========================================================
   Subir Joshi — portfolio
   Layout: "Clean Engineer"  ·  Accents: "Terminal" mono
   ========================================================== */

:root {
  --bg: #ffffff;
  --tint: #f5f7fa;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #1d4ed8;
  --accent-ink: #1e3a8a;
  --accent-soft: #eff6ff;
  --ok: #15803d;
  --dark: #0b0f0e;
  --dark-2: #121816;
  --dark-line: #2a3631;
  --dark-text: #e6edE9;
  --dark-dim: #a3b3ab;
  --mint: #4ade80;

  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 14px;
  --gutter: clamp(16px, 4vw, 32px);
  --max: 1160px;
  --section-y: clamp(64px, 9vw, 112px);
  --header-h: 68px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }

.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

.mono { font-family: var(--mono); }
.accent { color: var(--accent); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
}
.skip-link:focus { top: 12px; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px;
  border-radius: 10px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { min-height: 44px; padding: 8px 16px; font-size: .95rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.9);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.nav { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-family: var(--mono); font-weight: 500; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.nav-menu { display: flex; align-items: center; gap: clamp(16px, 2.4vw, 32px); }
.nav-menu a:not(.btn) { color: #334155; text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav-menu a:not(.btn):hover { color: var(--accent); }

.nav-toggle {
  display: none; width: 48px; height: 48px; margin-right: -8px;
  border: 0; background: transparent; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.nav-toggle-bar { width: 22px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .nav-menu {
    position: fixed; left: 0; right: 0; top: calc(var(--header-h) + env(safe-area-inset-top));
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; border-bottom: 1px solid var(--line);
    padding: 8px var(--gutter) 20px;
    box-shadow: 0 20px 40px -20px rgba(15,23,42,.25);
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity .2s, transform .2s, visibility .2s;
  }
  .nav-menu.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav-menu a:not(.btn) { padding: 14px 4px; font-size: 1.1rem; border-bottom: 1px solid var(--line); }
  .nav-menu .btn { margin-top: 16px; }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 72px);
  align-items: center;
  padding-block: clamp(48px, 8vw, 104px) clamp(48px, 7vw, 88px);
}
.hero-copy { display: flex; flex-direction: column; gap: clamp(18px, 2.5vw, 26px); min-width: 0; }
.status { display: inline-flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--ok); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 0 rgba(22,163,74,.5); animation: pulse 2.2s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
.hero h1 { font-size: clamp(2.25rem, 1.2rem + 4.4vw, 4.1rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.04; }
.lead { font-size: clamp(1.05rem, .95rem + .5vw, 1.25rem); color: var(--muted); max-width: 40em; }
.lead strong { color: var(--ink); }

.hero-media { position: relative; justify-self: center; width: min(100%, 360px); }
.hero-photo { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 22%; border-radius: 22px; }
.terminal {
  position: absolute; left: -28px; bottom: -24px;
  background: var(--dark-2); color: var(--dark-text);
  border: 1px solid var(--dark-line); border-radius: 12px;
  padding: 14px 18px; font-family: var(--mono); font-size: .8rem; line-height: 1.8;
  box-shadow: 0 24px 48px -20px rgba(0,0,0,.45);
  min-width: 250px;
}
.terminal .accent { color: var(--mint); }
.terminal .dim { color: var(--dark-dim); margin-bottom: 4px; }
.terminal .ok { color: #fcd34d; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-media { justify-self: start; width: min(100%, 440px); margin-bottom: 24px; }
  .hero-photo { aspect-ratio: 4 / 3; object-position: center 30%; }
  .terminal { left: auto; right: -12px; bottom: -20px; min-width: 0; font-size: .75rem; }
}
@media (max-width: 480px) {
  .hero-media { width: 100%; }
  .terminal { right: 12px; }
  .hero .btn-row .btn { flex: 1 1 100%; }
}

/* ---------- Proof strip ---------- */
.proof { background: var(--tint); border-block: 1px solid var(--line); }
.proof-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px; margin-block: 0; padding-block: 32px;
}
.proof-grid dt { font-size: clamp(1.4rem, 1rem + 1.4vw, 1.8rem); font-weight: 800; letter-spacing: -0.02em; }
.proof-grid dd { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
@media (max-width: 900px) { .proof-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 360px) { .proof-grid { grid-template-columns: 1fr; } }

/* ---------- Sections ---------- */
.section { padding-block: var(--section-y); }
.section-tint { background: var(--tint); border-block: 1px solid var(--line); }
.section-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: clamp(28px, 4vw, 44px); }
.section-head h2 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.6rem); max-width: 22ch; }
.section-sub { color: var(--muted); max-width: 46em; }
.eyebrow { font-size: .85rem; color: var(--accent); letter-spacing: 0; }

/* ---------- Tags ---------- */
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tag, .tags-light li {
  font-family: var(--mono); font-size: .78rem;
  background: var(--accent-soft); color: var(--accent-ink);
  padding: 5px 10px; border-radius: 6px; white-space: nowrap;
}

/* ---------- Featured ---------- */
.featured-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 3vw, 36px); }
@media (max-width: 720px) { .featured-grid { grid-template-columns: 1fr; } }

.feature {
  display: flex; flex-direction: column; gap: 14px;
  text-align: left; padding: 0; border: 0; background: none; cursor: pointer;
}
.feature-media {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  aspect-ratio: 16 / 10; background: var(--tint);
}
.feature-media img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .5s ease; }
.feature:hover .feature-media img { transform: scale(1.03); }
.feature h3 { font-size: clamp(1.3rem, 1.1rem + .6vw, 1.55rem); }
.feature p { color: var(--muted); }
.feature .more-link { font-weight: 700; color: var(--accent); }
.feature:hover h3 { color: var(--accent); }

/* Text tile when a project has no screenshot */
.tile {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(16px, 3vw, 28px);
  background: var(--dark-2); color: var(--dark-text);
  font-family: var(--mono);
}
.tile-cmd { font-size: .8rem; color: var(--dark-dim); }
.tile-cmd span { color: var(--mint); }
.tile-name { font-family: var(--sans); font-weight: 800; font-size: clamp(1.2rem, 1rem + 1vw, 1.7rem); letter-spacing: -0.02em; line-height: 1.1; }
.tile-stack { font-size: .75rem; color: var(--mint); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 320px; max-width: 520px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; padding: 10px 14px 10px 44px;
  border: 1.5px solid var(--line-strong); border-radius: 10px; background: #fff;
  font-size: 1rem; /* 16px stops iOS zoom-on-focus */
}
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(29,78,216,.18); }
.toolbar-right { display: flex; gap: 10px; align-items: center; }
.select {
  min-height: 48px; padding: 10px 38px 10px 14px; border-radius: 10px;
  border: 1.5px solid var(--line-strong); background: #fff;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23475569' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  font-size: 1rem; cursor: pointer;
}
.view-toggle { display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.view-toggle button { width: 48px; height: 45px; border: 0; background: transparent; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.view-toggle svg { fill: currentColor; }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }

@media (max-width: 560px) {
  .search { flex-basis: 100%; max-width: none; }
  .toolbar-right { width: 100%; }
  .toolbar-right .select { flex: 1; }
}

/* Chips: wrap on desktop, swipe on phones */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: #fff; cursor: pointer;
  font-weight: 600; font-size: .92rem; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip .n { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"] .n { color: #cbd5e1; }
@media (max-width: 640px) {
  .chips {
    flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); padding-bottom: 4px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { scroll-snap-align: start; }
}

.result-count { font-size: .85rem; color: var(--muted); margin-bottom: 20px; }

/* ---------- Project grid ---------- */
.project-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: clamp(16px, 2.4vw, 24px);
}
.card {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  padding: 0; transition: box-shadow .2s, transform .2s, border-color .2s;
}
.card:hover { box-shadow: 0 18px 36px -20px rgba(15,23,42,.35); transform: translateY(-2px); border-color: var(--line-strong); }
.card-media { aspect-ratio: 4 / 3; overflow: hidden; background: var(--tint); border-bottom: 1px solid var(--line); }
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.card-title { font-size: 1.1rem; font-weight: 700; line-height: 1.25; }
.card-sum { color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .tags { margin-top: auto; padding-top: 6px; }

/* List view */
.project-grid.is-list { grid-template-columns: 1fr; gap: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.is-list .card { flex-direction: row; align-items: center; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); gap: 16px; padding: 12px 16px; }
.is-list li:last-child .card { border-bottom: 0; }
.is-list .card:hover { transform: none; box-shadow: none; background: var(--tint); }
.is-list .card-media { flex: 0 0 96px; aspect-ratio: 4 / 3; border-radius: 8px; border: 1px solid var(--line); }
.is-list .tile { padding: 8px; }
.is-list .tile-cmd, .is-list .tile-stack { display: none; }
.is-list .tile-name { font-size: .7rem; }
.is-list .card-body { padding: 0; flex-direction: row; align-items: center; gap: 16px; flex-wrap: wrap; }
.is-list .card-title { flex: 1 1 220px; }
.is-list .card-meta { flex: 0 0 auto; order: 2; }
.is-list .card-sum { display: none; }
.is-list .tags { margin: 0; padding: 0; order: 3; }
@media (max-width: 560px) {
  .is-list .card { padding: 12px; gap: 12px; }
  .is-list .card-media { flex-basis: 72px; }
  .is-list .card-body { gap: 4px; flex-direction: column; align-items: flex-start; }
  .is-list .card-title { flex: none; font-size: 1rem; }
  .is-list .tags { display: none; }
}

.empty { text-align: center; padding: 48px 0; display: grid; gap: 16px; justify-items: center; color: var(--muted); }
.more { display: flex; justify-content: center; margin-top: 32px; }
.more .btn { min-width: min(100%, 280px); }

/* ---------- Experience ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(24px, 5vw, 64px); }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 24px;
  padding: 24px 0; border-top: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: 1px solid var(--line); }
.t-date { font-size: .85rem; color: var(--accent); padding-top: 3px; }
.timeline h3 { font-size: 1.15rem; line-height: 1.35; letter-spacing: -0.01em; }
.timeline p { color: var(--muted); margin-top: 6px; }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr; } }

/* ---------- Skills (dark band) ---------- */
.skills { background: var(--dark); color: var(--dark-text); padding-block: var(--section-y); }
.skills .eyebrow { color: var(--mint); }
.skills-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(28px, 5vw, 56px); }
@media (max-width: 720px) { .skills-grid { grid-template-columns: 1fr; } }
.skills h3 { font-size: 1rem; font-family: var(--mono); font-weight: 500; color: var(--dark-dim); margin-bottom: 16px; }
.skills .tags li {
  font-family: var(--mono); font-size: .85rem;
  border: 1px solid var(--dark-line); color: var(--dark-text);
  padding: 9px 13px; border-radius: 8px;
}

/* ---------- Contact / footer ---------- */
.contact { display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }
.contact h2 { font-size: clamp(1.9rem, 1.2rem + 3vw, 3.2rem); max-width: 20ch; letter-spacing: -0.03em; }
@media (max-width: 480px) { .contact .btn-row, .contact .btn { width: 100%; } .contact .btn { word-break: break-all; } }
.site-footer { border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding-block: 24px; font-size: .9rem; color: var(--muted); }
.footer-inner a { text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Project dialog ---------- */
.project-dialog {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 18px; background: #fff; color: var(--ink);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,.5);
  overflow: hidden;
}
.project-dialog::backdrop { background: rgba(11,15,14,.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.project-dialog[open] { display: flex; animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.dlg-inner { display: flex; flex-direction: column; width: 100%; max-height: inherit; min-height: 0; }
.dlg-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--line); background: var(--dark-2); color: var(--dark-dim); }
.dlg-path { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-path span { color: var(--mint); }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--dark-text); cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.dlg-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); min-height: 0; flex: 1; overflow: hidden; }
.dlg-media { overflow-y: auto; background: var(--tint); border-right: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.dlg-media img { width: 100%; height: auto; }
.dlg-media .tile { min-height: 320px; height: 100%; }
.dlg-info { padding: clamp(20px, 3vw, 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg-info h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
.dlg-role { font-weight: 600; }
.dlg-info > p:not(.eyebrow):not(.dlg-role) { color: var(--muted); }
.dlg-highlights { margin: 0; padding-left: 1.1em; color: var(--muted); display: grid; gap: 6px; }
.dlg-highlights:empty { display: none; }
.dlg-nav { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .project-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .dlg-inner { height: 100%; padding-top: env(safe-area-inset-top); }
  .dlg-body { grid-template-columns: 1fr; overflow-y: auto; display: block; }
  .dlg-media { max-height: 52dvh; border-right: 0; border-bottom: 1px solid var(--line); }
  .dlg-info { overflow: visible; }
  .dlg-nav { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .dlg-nav .btn { flex: 1; }
}

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
