/* =========================================================
   Ayush Sahni — portfolio
   Minimal, typewriter + scrollytelling layout
   ========================================================= */

:root {
  --ink: #111111;
  --ink-soft: #3a3a3a;
  --muted: #8f8f8f;
  --soft: #f9f9f9;
  --soft-2: #f2f2f2;
  --dark: #201c1c;
  --line: #e3e3e3;
  --icon-hover: #c4c4c4;
  --mono: 'Source Code Pro', ui-monospace, Menlo, Consolas, monospace;
  --head: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Cormorant Garamond', Georgia, serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: #201c1c; color: #fff; }

:focus-visible { outline: 2px solid var(--dark); outline-offset: 3px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  background: var(--dark);
  color: #fff;
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 14px;
  text-decoration: none;
}
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 90vw;
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 6px;
}

.icon-btn {
  background: none;
  border: 0;
  padding: 6px;
  margin: 0;
  cursor: pointer;
  color: #000;
  line-height: 0;
  border-radius: 6px;
  transition: color 0.3s ease;
}
.icon-btn:hover,
.icon-btn[aria-expanded="true"] { color: var(--icon-hover); }
.icon-btn svg { width: 26px; height: 26px; fill: currentColor; }

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  padding: 4px 0;
}
.logo-mark {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 46px;
  line-height: 0.95;
}
.logo-name {
  font-family: var(--head);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 1.8px;
  color: #a3a3a3;
  margin-top: 2px;
}

.menu-wrap, .share-wrap { position: relative; }

.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: #fff;
  border-radius: 4px;
  padding: 8px 0;
  box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.96) translateY(-4px);
  transform-origin: top left;
  /* visibility flips instantly on open (so the first link can take focus) and waits for the fade on close */
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}
.dropdown.open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.dropdown--right { left: auto; right: 0; min-width: 0; transform-origin: top right; }

.dropdown a {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--ink);
}
.dropdown a:hover,
.dropdown a:focus-visible { background: rgba(0, 0, 0, 0.05); outline: none; }
.dropdown a[aria-current="page"] { font-weight: 600; }
.dropdown .emoji { width: 24px; text-align: center; }
.dropdown--right a { padding: 10px 18px; }
.dropdown--right svg { width: 24px; height: 24px; fill: #000; }

/* ---------- Typewriter ---------- */
.tw { position: relative; }
.tw-ghost { color: transparent; }
.tw-live { position: absolute; inset: 0; }

/* ---------- Home intro ---------- */
main { position: relative; z-index: 1; }

.intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 90px);
  min-height: calc(100svh - 90px);
  padding: 10px 24px 40px;
}
.home-bio {
  width: min(560px, 100%);
  font-family: var(--mono);
  font-size: clamp(15px, 0.82em + 0.28vw, 19px);
  line-height: 1.45;
  margin-top: 30px;
}
.home-bio p { margin: 0 0 1.35em; }

.scroll-down {
  margin-top: 30px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: #d3d3d3;
  line-height: 0;
  opacity: 0;
  transition: color 0.3s ease, opacity 0.7s ease;
}
.scroll-down.show { opacity: 1; }
.scroll-down:hover { color: #424242; }
.scroll-down svg { width: 80px; height: 80px; fill: currentColor; }

/* ---------- Scrollytelling sections ---------- */
/* Text comes first in the DOM (so it leads on mobile); on desktop the default
   story puts cards left / text right, and the flipped one mirrors it. */
.story {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6vw;
  max-width: 1000px;
  margin: 0 auto;
  padding: 14vh 3vw 18vh;
}
.story--flip { flex-direction: row; }

.story-cards {
  flex: 0 0 34%;
  display: flex;
  flex-direction: column;
  gap: 7vh;
  min-width: 0;
}

.story-text {
  flex: 1 1 auto;
  position: sticky;
  top: 30vh;
  min-width: 0;
}
.story--flip .story-text { text-align: right; }

.poster {
  font-family: var(--body);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.25;
  margin: 0;
}
.brand {
  font-family: var(--head);
  font-weight: 600;
  font-size: 0.82em;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.inline-logo {
  display: inline-block;
  height: 1em;
  width: auto;
  vertical-align: middle;
  margin: 0 2px;
}

/* Side cards (home) */
.scard {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--soft);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.scard-img {
  height: clamp(180px, 33vh, 290px);
  overflow: hidden;
  background: #eee;
}
.scard-img img,
.hcard-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%);
  transition: filter 0.3s ease;
}
.scard:hover .scard-img img,
.scard:focus-visible .scard-img img { filter: grayscale(0%); }

.scard-body {
  padding: 18px 20px 20px;
  background: var(--soft);
  transition: background-color 0.3s ease, color 0.3s ease;
}
.scard:hover .scard-body,
.scard:focus-visible .scard-body { background: var(--dark); color: #fff; }

.scard-title {
  font-family: var(--head);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.25;
  margin: 0 0 10px;
}
.scard-text {
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 12px;
}
.meta {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
}
.meta span { display: block; }

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 225px;
  padding: 30px 20px 34px;
  text-align: center;
}
.footer-line {
  font-family: var(--mono);
  font-size: 16px;
  min-height: 1.5em;
  margin: 0;
}
.footer-icons {
  display: flex;
  gap: 18px;
  margin: 25px 0 6px;
}
.footer-icons a {
  color: #000;
  line-height: 0;
  transition: color 0.3s ease;
}
.footer-icons a:hover { color: var(--icon-hover); }
.footer-icons svg { width: 24px; height: 24px; fill: currentColor; }
.copyright {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  margin: 10px 0 0;
}

/* ---------- Back to top ---------- */
.to-top {
  position: fixed;
  bottom: 16px;
  right: max(24px, calc((100% - 900px) / 2 + 5%));
  z-index: 90;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: none;
  color: #d3d3d3;
  cursor: pointer;
  line-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: color 0.3s ease, opacity 0.3s ease;
}
.to-top.show { opacity: 0.85; pointer-events: auto; }
.to-top:hover { color: #424242; opacity: 1; }
.to-top svg { width: 100%; height: 100%; fill: currentColor; }

/* ---------- Inner pages ---------- */
.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px 40px;
}
.page-head {
  text-align: center;
  padding: 80px 10px 0;
}
.page-head h1 {
  font-family: var(--head);
  font-weight: 600;
  font-size: clamp(30px, 5vw, 40px);
  margin: 0 0 22px;
}
.page-intro {
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.5;
  max-width: 460px;
  min-height: 4.5em;
  margin: 0 auto;
}
.page-head .scroll-down { margin-top: 0; }
.page-head .scroll-down svg { width: 64px; height: 64px; }

.entry {
  max-width: 760px;
  margin: 0 auto;
  padding: 46px 0;
  scroll-margin-top: 20px;
}
.entry + .entry { border-top: 2px solid var(--line); }

/* Horizontal card (inner pages) */
.hcard {
  display: flex;
  height: 380px;
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12);
}
.hcard-content {
  width: 40%;
  padding: 18px 22px;
  background: var(--soft-2);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.hcard-img {
  width: 60%;
  overflow: hidden;
  background: var(--soft);
}
.hcard:hover .hcard-content { background: var(--dark); color: #fff; }
.hcard:hover .hcard-img img,
.hcard:hover .repo-cover { filter: grayscale(0%); }
.hcard-img.contain img { object-fit: contain; padding: 26px; background: #fff; }

.hcard-title {
  font-family: var(--head);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 6px;
}
.hcard-org {
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 10px;
}
.hcard-text {
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 12px;
}

.hcard--mini { height: 210px; }
.hcard--mini .hcard-content { width: 55%; }
.hcard--mini .hcard-img { width: 45%; }

.entry-body { padding: 26px 4px 0; }
.entry-body ul {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
  padding-left: 20px;
}
.entry-body li { margin-bottom: 8px; }
.entry-body p {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  margin: 0 0 12px;
}
.entry-body .entry-tools {
  font-family: var(--mono);
  font-size: 14px;
  color: #444;
  line-height: 1.6;
  margin: 14px 0 0;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 24px;
}
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid #3d3d3d;
  border-radius: 4px;
  color: #3d3d3d;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-decoration: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.btn-outline svg { width: 18px; height: 18px; fill: currentColor; }
.btn-outline:hover:not(:disabled) { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-outline:disabled { opacity: 0.35; cursor: not-allowed; }

.subhead {
  font-family: var(--head);
  font-weight: 600;
  font-size: 24px;
  text-align: center;
  margin: 80px 0 8px;
  scroll-margin-top: 20px;
}
.subhead-note {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 34px;
}

.stack { display: flex; flex-direction: column; gap: 22px; max-width: 760px; margin: 0 auto; }

.text-grid {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 28px 44px;
}
.text-grid h3 {
  font-family: var(--head);
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 4px;
}
.text-grid .role {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}
.text-grid p {
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}
.text-grid .mono-list {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: #444;
}

/* GitHub repo covers (generated, no image) */
.repo-cover {
  height: 100%;
  background: #0d1117;
  color: #e6edf3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  font-family: var(--mono);
  font-size: 13px;
  filter: grayscale(100%);
  transition: filter 0.3s ease;
  overflow: hidden;
}
.repo-cover .prompt { color: #7d8590; }
.repo-cover .name {
  color: #d29922;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.repo-cover .lang { color: #7d8590; display: flex; align-items: center; gap: 8px; }
.repo-cover .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.load-note { font-family: var(--mono); font-size: 14px; color: var(--muted); text-align: center; }
.load-note a { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .poster { font-size: 28px; }
  .story { gap: 5vw; }
  .story-cards { flex-basis: 38%; }
}

@media (max-width: 700px) {
  .story,
  .story--flip {
    flex-direction: column;
    align-items: stretch;
    padding: 12vh 0 8vh;
    gap: 36px;
    width: min(440px, calc(100% - 32px));
  }
  .story-text,
  .story--flip .story-text {
    position: static;
    order: -1;
    text-align: left;
  }
  .story-cards { gap: 34px; }
  .poster { font-size: 25px; }

  .hcard { flex-direction: column-reverse; height: auto; }
  .hcard-content,
  .hcard--mini .hcard-content { width: 100%; padding: 18px 20px; }
  .hcard-img,
  .hcard--mini .hcard-img { width: 100%; height: 220px; }
  .hcard--mini { height: auto; }
  .hcard--mini .hcard-img { height: 150px; }

  .page-head { padding-top: 50px; }
  .entry { padding: 36px 0; }
  .logo-mark { font-size: 40px; }
}

@media (max-width: 420px) {
  .poster { font-size: 22px; }
  .site-header { width: 100%; padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .scroll-down { opacity: 1; }
}

.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;
}
