/* ==========================================================================
   rgrishabh.in — design system
   One stylesheet, mobile-first, dark by default. No framework, no build step.

   Structure:  tokens → reset → primitives → layout → components → responsive
   Contrast:   text 16.5:1, muted 7.7:1, accent 6.3:1 on the base background.
   ========================================================================== */

/* ── tokens ──────────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg:        #08090c;
  --surface:   #0f1116;
  --surface-2: #14171d;
  --border:    #20242c;
  --border-hi: #2c323c;

  --text:      #e8eaed;   /* 16.5:1 */
  --muted:     #9aa1ad;   /*  7.7:1 */
  --dim:       #6e7480;

  --accent:    #5b8cff;   /*  6.3:1 — links, focus, primary action */
  --ok:        #3ddc97;   /* 11.3:1 — status only, never decoration */

  --radius:    10px;
  --radius-lg: 14px;

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

  --gutter: clamp(1.15rem, 5vw, 2.5rem);
  --maxw:   1180px;
}
:root { --accent-soft: rgba(91, 140, 255, 0.12); }

html[data-theme="light"] {
  color-scheme: light;
  --bg:        #fbfbfd;
  --surface:   #ffffff;
  --surface-2: #f4f5f8;
  --border:    #e3e5ea;
  --border-hi: #d2d6de;
  --text:      #12141a;
  --muted:     #5a6270;
  --dim:       #7b828e;
  --accent:    #2f5fd8;
  --ok:        #0f8a55;
  --accent-soft: rgba(47, 95, 216, 0.09);
}

/* ── reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  /* overflow-x hidden is a plaster; the layout must not overflow in the first
     place. This is a backstop only, paired with min-width:0 on every grid child. */
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4 { line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
p { text-wrap: pretty; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  padding: .7rem 1rem; background: var(--accent); color: #fff; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

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

/* ── primitives ──────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.mono { font-family: var(--mono); font-feature-settings: "liga" 0; }

.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}

.section { padding-block: clamp(3.25rem, 9vw, 6rem); }
.section + .section { border-top: 1px solid var(--border); }

.section-head { margin-bottom: clamp(1.5rem, 4vw, 2.25rem); }
.section-head h2 {
  margin-top: .45rem;
  font-size: clamp(1.4rem, 4.2vw, 1.9rem);
}
.section-head p {
  margin-top: .6rem;
  color: var(--muted);
  max-width: 58ch;
  font-size: .95rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px;                 /* touch target */
  padding: .65rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  font-size: .92rem; font-weight: 500;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border-hi); }

.tag {
  display: inline-flex; align-items: center;
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--muted);
  white-space: nowrap;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: clamp(1.1rem, 3.5vw, 1.5rem);
}

/* every grid child can shrink — this is what actually prevents overflow */
.grid > * { min-width: 0; }

/* ── header / nav ────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .header { background: var(--bg); } }

.header__inner {
  display: flex; align-items: center; gap: 1rem;
  min-height: 58px;
}
.brand {
  display: inline-flex; align-items: center;
  min-height: 44px;                 /* was 24px — the page's only AA touch-target failure */
  font-family: var(--mono); font-size: .92rem; font-weight: 600;
  letter-spacing: .02em; margin-right: auto;
}
.brand span { color: var(--accent); }

.nav { display: none; }
.nav a {
  padding: .45rem .1rem;
  font-size: .89rem; color: var(--muted);
  transition: color .16s ease;
}
.nav a:hover, .nav a[aria-current="true"] { color: var(--text); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;                /* touch target */
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); }

/* mobile drawer */
.drawer {
  position: fixed; inset: 58px 0 auto 0; z-index: 55;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: .5rem var(--gutter) 1.1rem;
  display: grid; gap: .15rem;
  transform: translateY(-8px); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.drawer[data-open="true"] { transform: none; opacity: 1; pointer-events: auto; }
.drawer a {
  padding: .8rem .2rem; font-size: 1rem; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.drawer a:last-child { border-bottom: 0; }

/* ── hero ────────────────────────────────────────────────────────────────── */
.hero { padding-block: clamp(2.25rem, 8vw, 4rem) clamp(1.25rem, 3vw, 2rem); }

.hero__status {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--mono); font-size: .75rem; color: var(--muted);
  margin-bottom: 1.1rem;
}
.dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none;
}

.hero__name {
  font-size: clamp(2.1rem, 11vw, 4rem);
  letter-spacing: -0.035em;
  overflow-wrap: break-word;        /* long name never overflows a 320px screen */
}
.hero__role {
  margin-top: .7rem;
  font-family: var(--mono);
  font-size: clamp(.8rem, 3.2vw, .95rem);
  color: var(--accent);
  overflow-wrap: break-word;
}
.hero__line {
  margin-top: 1.1rem;
  font-size: clamp(1rem, 3.6vw, 1.15rem);
  color: var(--muted);
  max-width: 54ch;
}

.hero__actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.6rem; }
.hero__links {
  display: flex; flex-wrap: wrap; gap: .4rem 1.1rem;
  margin-top: 1.4rem;
  font-family: var(--mono); font-size: .82rem;
}
.hero__links a { color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; }
.hero__links a:hover { color: var(--accent); }

/* ── terminal ────────────────────────────────────────────────────────────── */
.term {
  margin-top: clamp(2rem, 6vw, 2.75rem);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
}
.term__bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .8rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.term__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-hi); flex: none; }
.term__name { font-family: var(--mono); font-size: .72rem; color: var(--dim); margin-left: .3rem; }

.term__body {
  padding: .9rem 1rem;
  font-family: var(--mono);
  font-size: clamp(.72rem, 2.9vw, .8rem);
  line-height: 1.8;
  min-height: 190px;
  white-space: pre-wrap;
  overflow-wrap: break-word;        /* terminal output wraps on small screens */
}
.term__prompt { color: var(--accent); }
.term__key    { color: var(--muted); }
.term__val    { color: var(--text); }
.term__ok     { color: var(--ok); }
/* No blinking caret: WCAG 2.2.2 requires a pause control for anything
   that blinks past five seconds, and a caret is not worth that cost. */

.term__cmds {
  display: flex; flex-wrap: wrap; gap: .4rem;
  padding: .7rem 1rem; border-top: 1px solid var(--border); background: var(--surface-2);
}
.term__cmd {
  font-family: var(--mono); font-size: .74rem; color: var(--muted);
  padding: .5rem .7rem; min-height: 40px;
  border: 1px solid var(--border); border-radius: 6px;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.term__cmd:hover, .term__cmd[aria-pressed="true"] {
  color: var(--text); border-color: var(--accent); background: var(--accent-soft);
}

/* ── current stack ───────────────────────────────────────────────────────── */
.stack-grid {
  display: grid; gap: .55rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
}
.stack-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .8rem .85rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--mono); font-size: .82rem;
  transition: border-color .16s ease, background .16s ease;
}
.stack-item:hover { border-color: var(--border-hi); background: var(--surface-2); }
.stack-item b { font-weight: 500; }

/* ── skills ──────────────────────────────────────────────────────────────── */
.skill-groups { display: grid; gap: .85rem; }
.skill-group h3 {
  font-family: var(--mono); font-size: .76rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--dim); margin-bottom: .7rem;
}
.skill-tags { display: flex; flex-wrap: wrap; gap: .4rem; }

.tier {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .08em;
  padding: .12rem .34rem; border-radius: 4px; margin-left: .45rem;
}
.tier--core    { background: var(--accent-soft); color: var(--accent); }
.tier--working { background: var(--surface-2); color: var(--dim); }

/* ── timeline ────────────────────────────────────────────────────────────── */
.track { display: grid; gap: 0; }
.track__row {
  display: grid; gap: .15rem .9rem;
  grid-template-columns: auto 1fr;
  padding: .9rem 0;
  border-bottom: 1px solid var(--border);
}
.track__row:last-child { border-bottom: 0; }
.track__year {
  font-family: var(--mono); font-size: .78rem; color: var(--accent);
  grid-row: 1 / span 2; align-self: start; padding-top: .12rem;
  min-width: 8.5ch;
}
.track__role { font-weight: 500; font-size: .95rem; }
.track__org  { color: var(--muted); font-size: .86rem; }

/* ── experience ──────────────────────────────────────────────────────────── */
.roles { display: grid; gap: .85rem; }
.role__top {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .7rem;
  margin-bottom: .2rem;
}
.role__org { font-weight: 600; font-size: 1.02rem; }
.role__when {
  font-family: var(--mono); font-size: .75rem; color: var(--dim);
  margin-left: auto;
}
.role__title { color: var(--accent); font-size: .88rem; margin-bottom: .75rem; }
.role__points { display: grid; gap: .4rem; margin-bottom: .9rem; }
.role__points li {
  position: relative; padding-left: 1.05rem;
  color: var(--muted); font-size: .92rem;
}
.role__points li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--border-hi);
}
.role__tags { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ── projects ────────────────────────────────────────────────────────────── */
.projects { display: grid; gap: .85rem; }
.project h3 { font-size: 1.02rem; margin-bottom: .35rem; }
.project p { color: var(--muted); font-size: .92rem; margin-bottom: .85rem; }

/* ── contact ─────────────────────────────────────────────────────────────── */
.contact h2 { font-size: clamp(1.5rem, 5.5vw, 2.2rem); }
.contact p { color: var(--muted); margin-top: .7rem; max-width: 46ch; }
.contact__links { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.5rem; }

/* ── footer ──────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding-block: 1.75rem;
  color: var(--dim); font-size: .82rem;
}
.footer__inner { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.footer .mono { margin-left: auto; }

/* ── reveal ──────────────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ── breakpoints: additive only, mobile is the base ──────────────────────── */
@media (min-width: 640px) {
  .skill-groups { grid-template-columns: repeat(2, 1fr); }
  .projects     { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .nav { display: flex; gap: 1.5rem; }
  .nav-toggle { display: none; }
  .drawer { display: none; }
  .skill-groups { grid-template-columns: repeat(3, 1fr); }
  .projects     { grid-template-columns: repeat(3, 1fr); }
  .track__row   { grid-template-columns: 10ch 1fr auto; align-items: baseline; }
  .track__org   { text-align: right; }
}
@media (min-width: 1100px) {
  .hero__name { font-size: 4.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ── credential ──────────────────────────────────────────────────────────── */
.cred {
  display: inline-flex; align-items: center; gap: .85rem;
  margin-top: 1.5rem; padding: .7rem .95rem .7rem .7rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color .16s ease, background .16s ease;
}
.cred:hover { border-color: var(--border-hi); background: var(--surface-2); }
.cred img { width: 44px; height: 44px; flex: none; }
.cred span { display: grid; font-size: .78rem; color: var(--muted); line-height: 1.45; }
.cred b { color: var(--text); font-weight: 500; font-size: .86rem; }
