/* =========================================================
   Ritwik Pavan — shared site styles
   Extracted from the original Hardware Nation page so every
   page (index, investments, hardware-nation, contact) shares
   the same design system.
   ========================================================= */

:root,
[data-theme="light"] {
  --text-xs: clamp(.75rem, .72rem + .16vw, .82rem);
  --text-sm: clamp(.875rem, .84rem + .16vw, .95rem);
  --text-base: clamp(1rem, .96rem + .2vw, 1.08rem);
  --text-lg: clamp(1.2rem, 1rem + .4vw, 1.45rem);
  --text-xl: clamp(1.8rem, 1.3rem + 1.4vw, 3rem);
  --text-2xl: clamp(2.8rem, 1.7rem + 3.4vw, 5.8rem);

  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  --color-bg: #f3f3f1;
  --color-surface: #f7f7f4;
  --color-surface-2: #ecece7;
  --color-border: #d8d8d2;
  --color-grid: rgba(0, 0, 0, .035);
  --color-text: #111;
  --color-text-muted: #666;
  --color-text-faint: #888;

  --content: 1380px;
  /* Exact font stack from cursor.com. CursorGothic isn't publicly licensed,
     so browsers fall through to system-ui (San Francisco on macOS, Segoe UI
     on Windows). That gives the same clean modern grotesque feel cursor.com
     ships, without bundling a paid font. */
  --font-body: CursorGothic, "CursorGothic Fallback", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  --radius: 18px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --color-bg: #0f0f10;
  --color-surface: #141415;
  --color-surface-2: #1b1c1d;
  --color-border: #2a2a2d;
  --color-grid: rgba(255, 255, 255, .04);
  --color-text: #f2f2ef;
  --color-text-muted: #b5b5ad;
  --color-text-faint: #878780;
}

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text);
  text-transform: lowercase;
  background: var(--color-bg);
}
/* Preserve original case for things that shouldn't be lowercased: URLs displayed
   in chips, addresses, code, mono numbers. Add classes here when needed. */
.preserve-case { text-transform: none; }

a { text-decoration: none; color: inherit; }
button { font: inherit; background: none; border: none; color: inherit; cursor: pointer; }

/* -------- Shell + sticky rail -------- */
.shell {
  width: min(calc(100% - 2rem), var(--content));
  margin-inline: auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 7rem);
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 2.5rem 0 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--color-grid);
}

.brand {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2rem;
}

.nav { display: grid; gap: .15rem; }
.nav a {
  width: fit-content;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: .04em;
  padding: .18rem .38rem;
  border: 1px solid transparent;
}
.nav a.active,
.nav a:hover {
  color: var(--color-text);
  border-color: var(--color-text);
  background: color-mix(in srgb, var(--color-surface-2) 78%, transparent);
}

.rail-foot { display: grid; gap: .75rem; }

.icon-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1rem; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .45rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .02em;
}

.tiny { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-faint); letter-spacing: .04em; }

.theme-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 0;
}

/* Mobile hamburger menu — hidden by default, only visible at <=640px */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  color: var(--color-text);
}
.nav-toggle svg { width: 20px; height: 20px; }
.nav-toggle .icon-close { display: none; }
.rail[data-nav-open] .nav-toggle .icon-bars { display: none; }
.rail[data-nav-open] .nav-toggle .icon-close { display: inline-block; }
.theme-toggle svg { width: 14px; height: 14px; }
[data-theme="light"] .theme-toggle .moon { display: block; }
[data-theme="light"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

/* -------- Main + sections -------- */
main { padding: 2.5rem 0 5rem; display: grid; gap: 3.5rem; }

section { border-top: 1px solid var(--color-grid); padding-top: 1.1rem; }
section:first-of-type { border-top: 0; padding-top: 0; }

.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: .04em;
  margin-bottom: 1.25rem;
  /* Numbers are kept in the markup so the layout is identical to before, but
     hidden visually. Removing this rule will bring the section numbers back. */
  visibility: hidden;
}

h1 {
  font-size: var(--text-2xl);
  line-height: .92;
  letter-spacing: -.08em;
  font-weight: 700;
  max-width: 12ch;
  margin-bottom: 0;
}

.hero-sub {
  margin-top: .9rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: none;
  line-height: 1.45;
}

/* External link in the hero — points off-site to the full HWN site. */
.hero-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: 1.1rem;
  padding: .55rem .8rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .03em;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}
.hero-link:hover {
  border-color: var(--color-text);
  transform: translateY(-1px);
}
.hero-link::after {
  content: '↗';
  font-size: .95em;
  opacity: .7;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-head h2 {
  font-size: var(--text-xl);
  line-height: 1;
  letter-spacing: -.06em;
  font-weight: 700;
}
.count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: .04em;
  visibility: hidden;
}

/* -------- Card grids (used on HWN) -------- */
.doc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
  max-width: 1320px;
}
.rapid-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
  max-width: 1320px;
}

.card {
  position: relative;
  display: block;
  min-height: 440px;
  border: 1px solid var(--color-grid);
  overflow: hidden;
  background: var(--color-surface-2);
  border-radius: var(--radius);
  isolation: isolate;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease, filter 220ms ease;
}
.card.small { min-height: 320px; }

.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transform: scale(1.01);
  transition: transform 320ms ease, filter 320ms ease;
}

/* Per-card framing — shifts the crop so the subject (robot, head, shoes, etc.) stays in view. */
.card.matic img    { object-position: center 78%; }
.card.hyperice img { object-position: center 70%; }
.card.form img     { object-position: center 20%; }

/* Play indicator — every card on HWN points to a video, so signal it visually.
   Solid white circle, dark triangle, top-right corner of the card.
   pointer-events:none so clicks fall through to the anchor. */
.card::before {
  content: '';
  position: absolute;
  right: 1.25rem;
  top: 1.25rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23111111'><polygon points='8,5 20,12 8,19'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  z-index: 3;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: transform 220ms ease;
  pointer-events: none;
}
.card:hover::before { transform: scale(1.08); }
.card.small::before { width: 42px; height: 42px; background-size: 14px 14px; right: 1rem; top: 1rem; }

/* Hover preview — YouTube iframe slides over the still image when the user hovers a card.
   pointer-events: none lets clicks fall through to the card link so they trigger the modal. */
.card-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  animation: card-preview-in 360ms ease-out forwards;
}
@keyframes card-preview-in { to { opacity: 1; } }

/* Lightbox player — opens when a card is clicked. */
.video-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: video-modal-in 220ms ease-out both;
}
@keyframes video-modal-in { from { opacity: 0; } to { opacity: 1; } }
.video-modal-frame {
  position: relative;
  width: min(1100px, 92vw);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.video-modal-frame iframe { width: 100%; height: 100%; border: 0; }
.video-modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
  text-transform: none; /* override the global lowercase rule on the close glyph */
}
.video-modal-close:hover { background: rgba(255, 255, 255, 0.24); transform: scale(1.05); }

/* Two-layer overlay on each card:
   1) A tiled SVG fractal-noise pattern, blended with overlay for a cinematic
      film-grain texture across the image
   2) The dark bottom gradient that anchors the title text */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, .18) 42%, rgba(0, 0, 0, 0) 70%);
  background-repeat: repeat, no-repeat;
  background-size: 240px 240px, cover;
  background-blend-mode: overlay, normal;
  opacity: 1;
  transition: opacity 220ms ease, background 220ms ease;
}

.card:hover { transform: translateY(-4px); border-color: rgba(0, 0, 0, .18); box-shadow: 0 18px 44px rgba(0, 0, 0, .12); }
.card:hover img { transform: scale(1.035); filter: saturate(1.12) contrast(1.05); }

/* Per-brand hover tints (kept from the original) */
.card.onewheel:hover::after  { background: linear-gradient(to top, rgba(51, 90, 255, .82),  rgba(51, 90, 255, .24)  42%, rgba(0,0,0,0) 74%); }
.card.matic:hover::after     { background: linear-gradient(to top, rgba(255, 120, 62, .84), rgba(255, 120, 62, .22) 42%, rgba(0,0,0,0) 74%); }
.card.lightphone:hover::after{ background: linear-gradient(to top, rgba(39, 172, 124, .82), rgba(39, 172, 124, .2)  42%, rgba(0,0,0,0) 74%); }
.card.insta360:hover::after  { background: linear-gradient(to top, rgba(73, 117, 255, .82), rgba(73, 117, 255, .2)  42%, rgba(0,0,0,0) 74%); }
.card.hyperice:hover::after  { background: linear-gradient(to top, rgba(0, 221, 255, .82),  rgba(0, 221, 255, .22)  42%, rgba(0,0,0,0) 74%); }
.card.form:hover::after      { background: linear-gradient(to top, rgba(201, 255, 64, .82), rgba(201, 255, 64, .2)  42%, rgba(0,0,0,0) 74%); }
.card.impulse:hover::after   { background: linear-gradient(to top, rgba(255, 113, 62, .84), rgba(255, 113, 62, .22) 42%, rgba(0,0,0,0) 74%); }
.card.bondu:hover::after     { background: linear-gradient(to top, rgba(255, 92, 146, .84), rgba(255, 92, 146, .24) 42%, rgba(0,0,0,0) 74%); }
.card.sunday:hover::after    { background: linear-gradient(to top, rgba(116, 93, 255, .84), rgba(116, 93, 255, .24) 42%, rgba(0,0,0,0) 74%); }
.card.andromeda:hover::after { background: linear-gradient(to top, rgba(72, 199, 181, .84), rgba(72, 199, 181, .22) 42%, rgba(0,0,0,0) 74%); }

.overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1rem;
  z-index: 2;
  display: grid;
  gap: .28rem;
}
.eyebrow {
  font-size: .78rem;
  letter-spacing: -.01em;
  text-transform: none;
  color: rgba(255, 255, 255, .82);
  line-height: 1.35;
}
.title {
  font-size: clamp(1.3rem, 1rem + 1vw, 2.1rem);
  line-height: .98;
  letter-spacing: -.05em;
  font-weight: 700;
  color: #fff;
}

/* -------- Contact form -------- */
.form-grid {
  display: grid;
  gap: 1rem;
  max-width: 640px;
}
.form-field { display: grid; gap: .4rem; }
.form-field label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: .02em;
}
.form-field input,
.form-field textarea {
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .65rem .8rem;
  outline: none;
  transition: border-color 180ms ease, background 180ms ease;
}
.form-field input:focus,
.form-field textarea:focus { border-color: var(--color-text); }
.form-field textarea { min-height: 160px; resize: vertical; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .25rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1rem;
  border: 1px solid var(--color-text);
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}
.btn:hover { transform: translateY(-1px); opacity: .92; }
.form-note { font-size: var(--text-xs); color: var(--color-text-faint); }

/* -------- About / bio prose -------- */
.bio {
  max-width: 62ch;
  display: grid;
  gap: 1rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.55;
}
.bio .lede {
  font-size: var(--text-lg);
  line-height: 1.3;
  letter-spacing: -.01em;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: .25rem;
}
.bio p { color: var(--color-text); }
.bio p + p { color: var(--color-text-muted); }
.bio strong { font-weight: 600; }
.bio a {
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 35%, transparent);
  padding-bottom: 1px;
  transition: border-color 160ms ease, color 160ms ease;
}
.bio a:hover { border-bottom-color: var(--color-text); }

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  max-width: 1100px;
}
.work-item {
  display: grid;
  gap: .4rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  transition: transform 200ms ease, border-color 200ms ease, background 200ms ease;
}
.work-item:hover { transform: translateY(-2px); border-color: var(--color-text); }
.work-item .work-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: .06em;
}
.work-item .work-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.work-item .work-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.link-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .5rem;
  max-width: 720px;
  margin-top: .5rem;
}
.link-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem .8rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .04em;
  color: var(--color-text-muted);
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.link-list a:hover {
  color: var(--color-text);
  border-color: var(--color-text);
  transform: translateY(-1px);
}
.link-list a::after { content: '↗'; opacity: .6; }
.link-list a[data-internal]::after { content: '→'; }

@media (max-width: 760px) {
  .work-grid { grid-template-columns: 1fr; }
}

/* -------- Redirect helper -------- */
.redirect-wrap {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  max-width: 600px;
}
.redirect-wrap p { color: var(--color-text-muted); font-size: var(--text-sm); }

/* -------- Responsive --------
   Three real breakpoints:
     1100px — rapid-fire grid collapses from 3 columns to 2
      980px — sidebar moves to top, cards single-column (tablet portrait + mobile)
      640px — phone-tuned spacing, larger touch targets, smaller cards/modal */
@media (max-width: 1100px) {
  .rapid-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; gap: 1.5rem; }
  .rail {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--color-grid);
    padding: 2rem 0 1.25rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
  }
  .rail > div:first-child { display: contents; }
  .brand { margin-bottom: 0; order: -1; }
  .nav { display: flex; flex-wrap: wrap; gap: .25rem .35rem; }
  .icon-row { margin-top: 0; }
  main { padding: 1.75rem 0 3rem; gap: 2.5rem; }
  .doc-grid,
  .rapid-grid { grid-template-columns: 1fr; max-width: none; }
  .card { min-height: 360px; }
  .card.small { min-height: 280px; }
}

@media (max-width: 640px) {
  /* Mobile rail = compact top bar with brand + hamburger only.
     Nav links and social chips stay hidden until the user opens the menu. */
  .rail {
    flex-direction: column;
    align-items: stretch;
    padding: 1.1rem 0 1rem;
  }
  .rail > div:first-child {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 1rem;
    row-gap: 0;
  }
  .brand { margin-bottom: 0; grid-column: 1; }
  .nav-toggle { display: inline-flex; grid-column: 2; grid-row: 1; justify-self: end; }

  /* Hide the menu pieces until [data-nav-open] flips on */
  .nav,
  .icon-row { display: none; }

  .rail[data-nav-open] .nav {
    display: grid;
    grid-column: 1 / -1;
    gap: .15rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-grid);
  }
  .rail[data-nav-open] .nav a { padding: .55rem .6rem; }
  .rail[data-nav-open] .icon-row {
    display: flex;
    grid-column: 1 / -1;
    margin-top: .8rem;
    gap: .5rem;
  }

  .chip { min-width: 36px; height: 36px; }
  .theme-toggle { width: 36px; height: 36px; }

  main { padding: 1.25rem 0 2.5rem; gap: 2rem; }
  .card { min-height: 260px; }
  .card.small { min-height: 220px; }
  .card::before { width: 42px; height: 42px; right: 1rem; top: 1rem; background-size: 14px 14px; }
  .card.small::before { width: 36px; height: 36px; background-size: 12px 12px; right: .85rem; top: .85rem; }
  .overlay { padding: .85rem; }
  .title { font-size: clamp(1.2rem, 4.5vw, 1.6rem); }
  .bio { max-width: 100%; }
  .bio .lede { font-size: var(--text-base); }
  .form-grid { max-width: 100%; }
  .video-modal { padding: 1rem; }
  .video-modal-close { top: .75rem; right: .75rem; width: 38px; height: 38px; font-size: 1.25rem; }
}

@media (max-width: 420px) {
  /* Edge-to-edge modal on the smallest phones — no rounded corners, fills screen. */
  .video-modal { padding: 0; }
  .video-modal-frame { border-radius: 0; }
  .video-modal-close { top: .5rem; right: .5rem; background: rgba(0, 0, 0, 0.5); }
}

/* Devices with no fine pointer (phones, most tablets in touch mode) skip the
   hover preview — there's no hover to trigger it and the loading cost is wasted. */
@media (hover: none) {
  .card-preview { display: none !important; }
}
