/* ==========================================================================
   Arnav Kumar Lal - portfolio
   One theme: charcoal sheet, ink-white text, drafting blue accent,
   hairline rules, tabular numerals, square corners.
   ========================================================================== */

:root {
  --sheet:      #101315;
  --panel:      #171b1e;
  --panel-2:    #1c2124;
  --ink:        #e3e6e2;
  --ink-muted:  #949c97;
  --rule:       #2b3135;
  --rule-soft:  #23282c;
  --accent:     #6fb0d8;
  --accent-ink: #0d1113;
  --grid:       rgba(227, 230, 226, 0.05);
  --focus:      #6fb0d8;
  --plate:      #f7f8f5;

  --f-sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 68ch;
  --sheet-max: 1180px;
  --stub: 150px;

  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

body {
  margin: 0;
  background-color: var(--sheet);
  background-image:
    repeating-linear-gradient(to right, var(--grid) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px 40px);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 1rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; margin: 0; }
p { margin: 0 0 1rem; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--sheet-max); margin: 0 auto; padding: 0 var(--gutter); }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.6rem 1rem; z-index: 120;
}
.skip:focus { left: 0; }

/* --- controls ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--f-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms linear, color 120ms linear, background-color 120ms linear;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.is-pending {
  cursor: not-allowed;
  color: var(--ink-muted);
  border-style: dashed;
}
.btn.is-pending:hover { border-color: var(--rule); color: var(--ink-muted); }

.btn--solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--solid:hover { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn--solid.is-pending, .btn--solid.is-pending:hover {
  background: transparent; border-color: var(--rule); color: var(--ink-muted);
}

/* --- masthead ----------------------------------------------------------- */

.masthead {
  position: sticky; top: 0; z-index: 30;
  background: var(--sheet);
  background: color-mix(in srgb, var(--sheet) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.masthead__row { display: flex; align-items: center; gap: 1rem; min-height: 60px; }

.mark {
  display: inline-flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: var(--ink);
  font-family: var(--f-mono); font-size: 0.8125rem; margin-right: auto;
}
.mark__box { width: 30px; height: 30px; border: 1px solid var(--ink); display: grid; place-items: center; font-weight: 600; }

.nav { display: flex; gap: 1.15rem; }
.nav a {
  font-family: var(--f-mono); font-size: 0.8125rem; color: var(--ink-muted);
  text-decoration: none; padding: 0.25rem 0; border-bottom: 1px solid transparent;
}
.nav a:hover, .nav a:focus-visible { color: var(--ink); border-bottom-color: var(--accent); }

.masthead .btn { padding: 0.45rem 0.7rem; }

@media (max-width: 940px) { .nav { display: none; } }
@media (max-width: 520px) { .mark span:not(.mark__box) { display: none; } }

/* --- title block -------------------------------------------------------- */

.sheet { border: 1px solid var(--rule); border-top: none; background: var(--panel); }

.titleblock { display: grid; grid-template-columns: 1fr 300px; }
.titleblock__main { padding: clamp(2rem, 5vw, 3.75rem) clamp(1.5rem, 4vw, 3rem); align-self: center; }

.titleblock__name {
  font-size: clamp(2.5rem, 7vw, 4.75rem);
  letter-spacing: -0.035em; line-height: 0.98; margin-bottom: 0.35rem;
}

.dimline { display: block; width: 100%; max-width: 560px; height: 20px; margin: 0.75rem 0 1.5rem; }
.dimline line { stroke: var(--accent); stroke-width: 1; fill: none; }
.dimline text { font-family: var(--f-mono); font-size: 9px; fill: var(--accent); letter-spacing: 0.04em; }
.dimline .measure { stroke-dasharray: 560; stroke-dashoffset: 560; animation: draw 900ms ease-out 120ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .dimline .measure { stroke-dashoffset: 0; animation: none; } }

.titleblock__lead { font-size: 1.0625rem; max-width: 60ch; }
.titleblock__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }

.titleblock__side { border-left: 1px solid var(--rule); display: grid; align-content: start; }
.titleblock__portrait { width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-bottom: 1px solid var(--rule); }

.meta-cell { border-bottom: 1px solid var(--rule); padding: 0.7rem 1rem; font-family: var(--f-mono); font-size: 0.75rem; }
.meta-cell:last-child { border-bottom: none; }
.meta-cell dt { color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.6875rem; margin-bottom: 0.15rem; }
.meta-cell dd { margin: 0; }
.meta-cell a { color: var(--ink); text-decoration-color: var(--rule); }
.meta-cell a:hover { color: var(--accent); }

@media (max-width: 860px) {
  .titleblock { grid-template-columns: 1fr; }
  .titleblock__side { border-left: none; border-top: 1px solid var(--rule); }
}

/* --- sections ----------------------------------------------------------- */

.section { border-top: 1px solid var(--rule); padding: clamp(2.5rem, 6vw, 4.5rem) 0; scroll-margin-top: 70px; }

.section__head { display: grid; grid-template-columns: var(--stub) 1fr; gap: 1.5rem; margin-bottom: 2.25rem; }
.section__tag { font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-muted); padding-top: 0.4rem; border-top: 2px solid var(--accent); }
.section__title { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 0.6rem; }
.section__note { color: var(--ink-muted); max-width: 62ch; margin: 0; }

@media (max-width: 720px) {
  .section__head { grid-template-columns: 1fr; gap: 0.75rem; }
}

/* --- entries ------------------------------------------------------------ */

.entry { border-top: 1px solid var(--rule-soft); padding: 2rem 0; }
.entry:first-of-type { border-top: 1px solid var(--rule); }
.entry__head { display: grid; grid-template-columns: var(--stub) 1fr; gap: 1.5rem; align-items: start; }

.entry__when { font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-muted); line-height: 1.5; }
.entry__when span { display: block; }

.entry__role { font-size: 1.1875rem; margin-bottom: 0.2rem; }
.entry__org { font-family: var(--f-mono); font-size: 0.8125rem; color: var(--ink-muted); margin-bottom: 1rem; }
.entry__body > p { margin-bottom: 0.9rem; }

@media (max-width: 720px) {
  .entry__head { grid-template-columns: 1fr; gap: 0.6rem; }
  .entry__when span { display: inline; }
  .entry__when span + span::before { content: " / "; }
}

/* --- documents ---------------------------------------------------------- */

.docs {
  margin-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
  padding-top: 1rem;
  display: grid;
  gap: 0.5rem;
}
.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule-soft);
  background: var(--panel);
}
.doc:hover { border-color: var(--rule); }
.doc__name { font-size: 0.9375rem; }
.doc__meta { display: block; font-family: var(--f-mono); font-size: 0.6875rem; color: var(--ink-muted); margin-top: 0.15rem; }
.doc .btn { white-space: nowrap; }

.note {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  color: var(--ink-muted);
  margin-top: 0.75rem;
  max-width: 62ch;
}

@media (max-width: 560px) {
  .doc { grid-template-columns: 1fr; gap: 0.6rem; }
  .doc .btn { justify-content: center; }
}

/* --- figures ------------------------------------------------------------ */

.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.fig { margin: 0; }

.fig__frame {
  display: block; position: relative; width: 100%; margin: 0;
  padding: 0.5rem; aspect-ratio: 4 / 3;
  border: 1px solid var(--rule); border-radius: 0;
  background: var(--plate); cursor: zoom-in; overflow: hidden;
}
.fig__frame img { width: 100%; height: 100%; object-fit: contain; }
.fig__frame--photo { padding: 0; background: var(--panel-2); }
.fig__frame--photo img { object-fit: cover; }
.fig__frame:hover { border-color: var(--accent); }
.fig__frame:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.fig figcaption { font-family: var(--f-mono); font-size: 0.6875rem; color: var(--ink-muted); margin-top: 0.45rem; line-height: 1.45; }
.fig figcaption b { color: var(--ink); font-weight: 600; }

/* --- lightbox ----------------------------------------------------------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 10, 11, 0.94);
  display: grid; place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
}
.lightbox[hidden] { display: none; }
body.is-zoomed .masthead { visibility: hidden; }
.lightbox__figure { margin: 0; max-width: 100%; display: grid; gap: 0.75rem; justify-items: center; }
.lightbox__figure img {
  max-width: min(1100px, 100%); max-height: 78vh; width: auto;
  background: var(--plate); border: 1px solid #3a4044; padding: 0.5rem; object-fit: contain;
}
.lightbox__figure figcaption { font-family: var(--f-mono); font-size: 0.75rem; color: #cfd4cf; text-align: center; max-width: 60ch; }
.lightbox__close { position: absolute; top: 1rem; right: 1rem; }

/* --- skills table ------------------------------------------------------- */

.skills { display: grid; border: 1px solid var(--rule); background: var(--panel); }
.skills__row { display: grid; grid-template-columns: 200px 1fr; border-bottom: 1px solid var(--rule-soft); }
.skills__row:last-child { border-bottom: none; }
.skills__row dt { font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-muted); padding: 0.85rem 1rem; border-right: 1px solid var(--rule-soft); }
.skills__row dd { margin: 0; padding: 0.85rem 1rem; font-size: 0.9375rem; }
@media (max-width: 620px) {
  .skills__row { grid-template-columns: 1fr; }
  .skills__row dt { border-right: none; padding-bottom: 0; }
}

/* --- certificate index -------------------------------------------------- */

.certs { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0; border: 1px solid var(--rule); background: var(--panel); }
.certs li { padding: 0.85rem 1rem; border-bottom: 1px solid var(--rule-soft); border-right: 1px solid var(--rule-soft); }
.certs h3 { font-size: 0.9375rem; margin-bottom: 0.15rem; }
.certs p { font-family: var(--f-mono); font-size: 0.6875rem; color: var(--ink-muted); margin: 0; }

/* --- contact ------------------------------------------------------------ */

.form { max-width: 620px; }
@media (min-width: 861px) { .form { margin-left: calc(var(--stub) + 1.5rem); } }

.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; }
.field label { font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-muted); }
.field input, .field textarea {
  font-family: var(--f-sans); font-size: 0.9375rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule); border-radius: 0;
  padding: 0.65rem 0.7rem; width: 100%;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--accent); }
.field textarea { min-height: 150px; resize: vertical; }

.form__status { font-family: var(--f-mono); font-size: 0.75rem; margin-top: 0.75rem; min-height: 1.2em; }
.form__status[data-state="error"] { color: #e08b7d; }

/* --- footer ------------------------------------------------------------- */

.footer { border-top: 1px solid var(--rule); padding: 1.75rem 0 3rem; }
.footer__row { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-muted); }
.footer__row a { color: var(--ink-muted); text-decoration-color: var(--rule); }
.footer__row a:hover { color: var(--accent); }
.footer__spacer { margin-left: auto; }

/* --- legal pages -------------------------------------------------------- */

.legal { padding: clamp(2.5rem, 6vw, 4rem) 0; }
.legal h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); margin-bottom: 0.5rem; }
.legal h2 { font-size: 1.125rem; margin: 2rem 0 0.6rem; }
.legal .updated { font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-muted); margin-bottom: 2rem; }
.legal ul { max-width: var(--measure); padding-left: 1.1rem; }
.legal li { margin-bottom: 0.5rem; }
