/* ==========================================================================
   Hiranya Agarwal / engineering portfolio
   Direction     Print magazine, engineering edition. Big photographs of real
                 hardware, big type with a voice, numbered callouts on the
                 photographs the way a build log annotates a picture.
   Palette       Bone ground, ink, competition red, navy for inverted panels
   Type          Bricolage Grotesque display / Source Serif 4 body /
                 IBM Plex Mono for the callout numbers and data only
   Signature     Numbered callouts pinned to real photographs
   ========================================================================== */

:root {
  /* Ground and its lightness shifts. No pure white anywhere. */
  --bone: #efede7;
  --bone-2: #e5e2da;
  --bone-3: #d6d2c7;
  --rule: #c9c4b8;

  /* Ink. 15.1:1, 9.4:1 and 5.2:1 on bone. */
  --ink: #15171a;
  --ink-2: #3e4247;
  --ink-3: #5c6167;

  /* Competition red. The 41103A number plate. 5.9:1 on bone, white on it 5.1:1. */
  --red: #c4301c;
  --red-deep: #9e2414;
  --red-wash: #f3ddd7;

  /* Navy for inverted panels. Pedare uniform, not neutral grey. */
  --navy: #0e1b2e;
  --navy-2: #16273f;
  --navy-rule: #2a3d58;
  --on-navy: #d5d9df;
  --on-navy-quiet: #8e98a6;
  --red-lift: #ff6b4e; /* red on navy only, 6.0:1 there. Never on bone. */

  /* Type */
  --display: "Bricolage Grotesque", "Arial Narrow", sans-serif;
  --body: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "Courier New", monospace;

  /* Scale, ratio 1.333 from an 18px body (editorial) */
  --t-micro: 0.75rem;
  --t-data: 0.8125rem;
  --t-meta: 0.9375rem;
  --t-body: 1.125rem;
  --t-lede: 1.5rem;
  --t-h3: 2rem;
  --t-h2: clamp(2.5rem, 1.6rem + 3.4vw, 4.75rem);
  --t-h1: clamp(2.75rem, 1.4rem + 6vw, 7.5rem);
  --t-giant: clamp(5rem, 2rem + 14vw, 16rem);

  /* Space, 8px grid */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 16px;
  --s-4: 24px;
  --s-5: 32px;
  --s-6: 48px;
  --s-7: 64px;
  --s-8: 96px;
  --s-9: 128px;
  --s-10: 192px;

  /* Radius, scaled by element size */
  --r-xs: 3px;    /* chips */
  --r-sm: 8px;    /* buttons, small media */
  --r-md: 14px;   /* panels */
  --r-lg: 20px;   /* large photographs */
  --r-full: 999px;

  --lift-1: 0 2px 6px rgba(21, 23, 26, .06), 0 10px 28px rgba(21, 23, 26, .08);
  --lift-2: 0 6px 14px rgba(21, 23, 26, .08), 0 24px 56px rgba(21, 23, 26, .14);

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 160ms;
  --t-mid: 320ms;

  --shell: 1360px;
  --gutter: clamp(20px, 4vw, 56px);
}

/* --------------------------------------------------------- reset + shell */

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

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

html:focus-within { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-body);
  line-height: 1.6;
  font-optical-sizing: auto;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

.shell {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* --------------------------------------------------------- typography */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 88;
  color: var(--ink);
  margin: 0 0 var(--s-3);
  text-wrap: balance;
  overflow-wrap: break-word;
}

h1 {
  font-size: var(--t-h1);
  line-height: .96;
  letter-spacing: -.035em;
}

h2 {
  font-size: var(--t-h2);
  line-height: .98;
  letter-spacing: -.03em;
}

h3 {
  font-size: var(--t-h3);
  line-height: 1.05;
  letter-spacing: -.025em;
  font-variation-settings: "opsz" 96, "wdth" 92;
}

p { margin: 0 0 var(--s-3); max-width: 66ch; }

p:last-child { margin-bottom: 0; }

strong { font-weight: 600; }

.lede {
  font-size: var(--t-lede);
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 44ch;
}

.note { color: var(--ink-3); max-width: 60ch; }

/* Small mono for measured things only. */
.data {
  font-family: var(--mono);
  font-size: var(--t-data);
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--red);
}

/* Eyebrow above a section title. Display face, not mono, so the page does
   not read as a wall of code labels. */
.kicker {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: 0 0 var(--s-4);
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--t-meta);
  letter-spacing: -.005em;
  color: var(--red);
}

.kicker::before {
  content: "";
  width: 28px;
  height: 3px;
  background: var(--red);
  border-radius: var(--r-full);
  flex: none;
}

.on-navy .kicker { color: var(--red-lift); }
.on-navy .kicker::before { background: var(--red-lift); }

/* --------------------------------------------------------- focus + links */

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

.on-navy :focus-visible,
.on-navy:focus-visible { outline-color: var(--red-lift); }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
}

.skip-link:focus-visible {
  left: var(--gutter);
  top: var(--s-2);
  background: var(--ink);
  color: var(--bone);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-family: var(--display);
  font-weight: 600;
}

a { color: var(--red); }

a:hover { color: var(--red-deep); }

.text-link {
  color: var(--ink);
  font-weight: 600;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--red);
  text-underline-offset: .18em;
  transition: color var(--t-fast) var(--ease), text-decoration-color var(--t-fast) var(--ease);
}

.text-link:hover { color: var(--red); }

.on-navy .text-link { color: #fff; text-decoration-color: var(--red-lift); }
.on-navy .text-link:hover { color: var(--red-lift); }

.on-navy { background: var(--navy); color: var(--on-navy); }
.on-navy h1, .on-navy h2, .on-navy h3 { color: #fff; }
.on-navy p { color: var(--on-navy); }
.on-navy .note { color: var(--on-navy-quiet); }
.on-navy .data { color: var(--red-lift); }

/* --------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 52px;
  padding: 0 var(--s-4);
  border: 2px solid var(--ink);
  border-radius: var(--r-full);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

a.btn-primary,
a.btn-primary:visited,
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bone);
}

a.btn-primary:hover,
.btn-primary:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn-quiet { background: transparent; color: var(--ink); }

.btn-quiet:hover { background: var(--ink); color: var(--bone); }

.btn:active { transform: translateY(1px); }

.on-navy .btn-quiet { border-color: #fff; color: #fff; }
.on-navy .btn-quiet:hover { background: #fff; color: var(--navy); }

/* --------------------------------------------------------- copy button */
/* Inserted by site.js next to anything carrying data-copy, so a dead button
   never ships when the clipboard is unavailable. */

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  margin-left: var(--s-2);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--t-data);
  letter-spacing: 0;
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.copy-btn svg { width: 14px; height: 14px; flex: none; }

.copy-btn:hover { background: var(--ink); border-color: var(--ink); color: var(--bone); }

.copy-btn.is-done { background: var(--red); border-color: var(--red); color: #fff; }

.on-navy .copy-btn,
.site-footer .copy-btn { border-color: var(--navy-rule); color: var(--on-navy); }

.site-footer .copy-btn { border-color: var(--rule); color: var(--ink-2); min-height: 32px; }

.on-navy .copy-btn:hover { background: #fff; border-color: #fff; color: var(--navy); }

.copy-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* --------------------------------------------------------- tags */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tags li {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--t-meta);
  letter-spacing: -.005em;
  color: var(--ink-2);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-full);
  padding: 3px 12px;
}

.on-navy .tags li { color: var(--on-navy); border-color: var(--navy-rule); }

/* --------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bone);
  border-bottom: 1px solid var(--rule);
}

.site-header .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: var(--r-full);
  background: var(--red);
  flex: none;
  transition: transform var(--t-fast) var(--ease);
}

.brand:hover .brand-mark { transform: scale(1.35); }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-full);
  color: var(--ink-2);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.005em;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.site-nav a:hover { color: var(--ink); background: var(--bone-2); }

.site-nav a.is-current { color: var(--red); }

.site-nav .nav-contact {
  margin-left: var(--s-2);
  background: var(--ink);
  color: var(--bone);
  padding: 0 18px;
}

.site-nav .nav-contact:hover { background: var(--red); color: #fff; }

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

.site-footer { border-top: 1px solid var(--rule); }

.site-footer .shell {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  padding-block: var(--s-5);
  font-size: var(--t-meta);
  color: var(--ink-3);
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-2);
  text-decoration: none;
}

.site-footer a:hover { color: var(--red); text-decoration: underline; }

/* --------------------------------------------------------- annotated photo */
/* The signature. A real photograph with numbered markers pinned to the real
   parts. Each marker is a button, so it works on keyboard and touch; the
   legend underneath repeats the notes so nobody has to hover to read them. */

.annotated {
  position: relative;
  margin: 0;
}

.annotated .frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--bone-2);
  line-height: 0;
}

.annotated .frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.marks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 2;
}

.mark button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--r-full);
}

.mark button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  border: 2px solid rgba(255, 255, 255, .55);
  transition: transform var(--t-mid) var(--ease), opacity var(--t-mid) var(--ease);
  opacity: 0;
  transform: scale(.6);
}

.mark button span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
  font-size: var(--t-data);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 4px 14px rgba(0, 0, 0, .35);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.mark:hover button span,
.mark.is-open button span,
.mark button:focus-visible span { transform: scale(1.12); background: var(--red-deep); }

.mark:hover button::before,
.mark.is-open button::before { opacity: 1; transform: scale(1); }

.mark .tip {
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  width: max-content;
  max-width: min(260px, 60vw);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bone);
  font-family: var(--body);
  font-size: var(--t-meta);
  line-height: 1.4;
  box-shadow: var(--lift-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.mark .tip b {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  margin-bottom: 2px;
}

.mark.flip .tip {
  left: auto;
  right: calc(100% + 6px);
  transform: translateY(-50%) translateX(6px);
}

.mark:hover .tip,
.mark:focus-within .tip,
.mark.is-open .tip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  list-style: none;
  margin: var(--s-3) 0 0;
  padding: 0;
  font-size: var(--t-meta);
  color: var(--ink-3);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.legend i {
  font-style: normal;
  font-family: var(--mono);
  font-weight: 600;
  font-size: var(--t-micro);
  color: var(--red);
}

.annotated figcaption {
  margin-top: var(--s-3);
  font-size: var(--t-meta);
  color: var(--ink-3);
}

.annotated figcaption b { color: var(--ink); font-weight: 600; }

/* --------------------------------------------------------- photographs */

.photo {
  margin: 0;
  background: var(--bone-2);
  border-radius: var(--r-md);
  padding: var(--s-2);
}

.photo img {
  display: block;
  width: 100%;
  height: auto;
  /* concentric: 14 outer minus 8 padding */
  border-radius: calc(var(--r-md) - var(--s-2));
  background: var(--bone-3);
}

.photo figcaption { padding: var(--s-3) var(--s-2) var(--s-2); }

.photo figcaption b {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -.01em;
  margin-bottom: 2px;
}

.photo figcaption span { display: block; font-size: var(--t-meta); color: var(--ink-3); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: var(--s-3);
  margin: var(--s-5) 0 0;
}

.photo-grid .wide { grid-column: 1 / -1; }

/* Mixed portrait and landscape frames sit in one row, so non-wide photos share one aspect. */
.photo-grid .photo:not(.wide) img { aspect-ratio: 4 / 3; object-fit: cover; }

.photo .zoom { display: none; }

.js-lightbox .photo img { cursor: zoom-in; }

.js-lightbox .photo .zoom {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  margin-top: var(--s-1);
  padding: 0;
  background: none;
  border: 0;
  color: var(--red);
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--t-meta);
  cursor: zoom-in;
  transition: color var(--t-fast) var(--ease), gap var(--t-fast) var(--ease);
}

.js-lightbox .photo .zoom:hover { color: var(--red-deep); gap: var(--s-3); }

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

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--s-3);
  padding: clamp(16px, 3vw, 40px);
  background: rgba(14, 27, 46, .95);
  border: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.lightbox:not([open]) { display: none; }

.lightbox::backdrop { background: rgba(14, 27, 46, .95); }

.lightbox-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.lightbox-stage img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--r-sm);
  object-fit: contain;
}

.lightbox-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-3);
  background: var(--navy-2);
  border-radius: var(--r-sm);
  color: var(--on-navy);
}

.lightbox-caption { font-size: 1rem; max-width: 70ch; margin: 0; }

.lightbox-caption b {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  color: #fff;
}

.lightbox-close {
  min-height: 44px;
  padding: 0 var(--s-4);
  background: none;
  border: 2px solid var(--navy-rule);
  border-radius: var(--r-full);
  color: #fff;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  flex: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.lightbox-close:hover { background: var(--navy); border-color: var(--on-navy-quiet); }

.lightbox :focus-visible { outline-color: var(--red-lift); }

/* --------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------- small screens */

@media (max-width: 900px) {
  .site-nav a { padding: 0 10px; font-size: var(--t-meta); }
  .site-nav .nav-contact { padding: 0 14px; }
}

@media (max-width: 720px) {
  .site-header { position: static; }
  .site-header .shell {
    flex-wrap: wrap;
    padding-block: var(--s-2);
  }
  .site-nav { width: 100%; flex-wrap: wrap; }
  .site-nav a { padding: 0 8px; }

  .mark button { width: 40px; height: 40px; }
  .mark button span { width: 26px; height: 26px; font-size: var(--t-micro); }
  .mark .tip { max-width: min(220px, 56vw); font-size: .875rem; }

  .lightbox { gap: var(--s-2); padding: var(--s-2); }
  .lightbox-bar { align-items: stretch; padding: var(--s-2); }
  .lightbox-caption { font-size: .9375rem; }
  .lightbox-close { width: 100%; }
}

@media (max-width: 380px) {
  .brand-text { display: none; }
}
