/*
  Layout: bento grid from arjunmahesh.com (2fr / 1fr / 1fr, 6px gaps, 8px radii,).
  Left tile text: reading column and list styling from benji.org.
  Font: Graphik is a commercial typeface, so it only applies if it is installed locally.
  Hanken Grotesk is the free stand-in. To use licensed Graphik files, add @font-face rules for
  "Graphik" (300/400/500) pointing at your own copies in /fonts.
*/

/* Colour tokens are registered so they can animate: the theme switch fades every colour together
   from the root, instead of each element fading on its own (which made text vanish mid-switch). */
@property --bg { syntax: "<color>"; inherits: true; initial-value: #fff; }
@property --tile { syntax: "<color>"; inherits: true; initial-value: #f5f5f5; }
@property --line { syntax: "<color>"; inherits: true; initial-value: #e6e6e6; }
@property --fg { syntax: "<color>"; inherits: true; initial-value: #303030; }
@property --ink { syntax: "<color>"; inherits: true; initial-value: #000; }
@property --muted { syntax: "<color>"; inherits: true; initial-value: #a1a1a1; }
@property --hair { syntax: "<color>"; inherits: true; initial-value: rgba(163, 163, 163, 0.25); }
@property --underline { syntax: "<color>"; inherits: true; initial-value: rgba(0, 0, 0, 0.18); }

:root {
  /* Light theme (palette from shivanimatlapudi.com) */
  --bg: #fff;
  --tile: #f5f5f5;
  --line: #e6e6e6;
  --fg: #303030;
  --ink: #000;
  --muted: #a1a1a1;
  --hair: rgba(163, 163, 163, 0.25);
  --underline: rgba(0, 0, 0, 0.18);
  --gap: 6px;
  --radius: 8px;
  --sans: Graphik, "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Dark theme (toggle top right of the name row; saved in localStorage, shared with the other pages) */
html[data-theme="dark"] {
  --bg: #121212;
  --tile: #1d1d1d;
  --line: #2c2c2c;
  --fg: #cfcfcf;
  --ink: #fff;
  --muted: #8a8a8a;
  --hair: rgba(255, 255, 255, 0.13);
  --underline: rgba(255, 255, 255, 0.25);
}

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

html { background: var(--bg); color-scheme: light; transition: --bg 0.3s ease, --tile 0.3s ease, --line 0.3s ease, --fg 0.3s ease, --ink 0.3s ease, --muted 0.3s ease, --hair 0.3s ease, --underline 0.3s ease; }
html[data-theme="dark"] { color-scheme: dark; }

::selection { background: var(--ink); color: var(--bg); }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.02em;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }

/* ---------- Stage + grid ---------- */

.stage { padding: var(--gap); }

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

.tile {
  position: relative;
  min-height: 400px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--tile);
  opacity: 0;
  animation: tileFadeIn 0.4s ease-out forwards;
}

@keyframes tileFadeIn { to { opacity: 1; } }

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .tile--about { grid-column: 1 / -1; min-height: 560px; }
}

/* Desktop: the page scrolls. Every screen holds four boxes (two rows of two, the same box shape as
   before); the text tile stays put on the left while the boxes scroll past on the right. */
@media (min-width: 1024px) {
  .grid {
    grid-template-columns: 2fr 1fr 1fr;
    grid-auto-rows: calc((100vh - 18px) / 2);
    grid-auto-rows: calc((100dvh - 18px) / 2);
  }
  .tile { min-height: 0; }
  .tile--about {
    grid-column: 1;
    grid-row: 1 / 5;
    align-self: start;
    position: sticky;
    top: var(--gap);
    height: calc(100vh - 2 * var(--gap));
    height: calc(100dvh - 2 * var(--gap));
    min-height: 0;
  }
}

/* ---------- Left tile: benji.org-style text ---------- */

.tile--about { border: 1px solid var(--line); }

.about {
  height: 100%;
  overflow-y: auto;
  padding: clamp(40px, 9vh, 80px) 20px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.about__col {
  max-width: 550px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 20px;
  font-weight: 460;
  letter-spacing: -0.006em;
}

.about__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 8px; }
.about__head h1 { font-size: inherit; line-height: inherit; font-weight: 500; letter-spacing: inherit; color: var(--ink); }

.about__col > p { padding-top: 16px; }
.about__contact { overflow-wrap: anywhere; }

.basic-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--underline);
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}
.basic-link:hover { text-decoration-color: var(--fg); }

/* Copy-to-clipboard button after the email */

.copy {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0 0 0 6px;
  padding: 0;
  vertical-align: -5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}
.copy:hover { color: var(--ink); background: var(--hair); }
.copy:focus-visible { outline: 2px solid var(--muted); outline-offset: 1px; }
.copy svg { grid-area: 1 / 1; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.15s, transform 0.15s; }
.copy__done { opacity: 0; transform: scale(0.7); }
.copy.is-copied { color: var(--ink); }
.copy.is-copied .copy__icon { opacity: 0; transform: scale(0.7); }
.copy.is-copied .copy__done { opacity: 1; transform: none; }
.copy-wrap { position: relative; display: inline-block; }
.copy__msg {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
}
.copy__msg:empty { display: none; }

/* Light / dark toggle */

.theme {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--hair);
}
.theme__btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.2s;
}
.theme__btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.theme__btn:hover { color: var(--ink); }
.theme__btn[aria-pressed="true"] { color: var(--ink); }

/* The raised circle is one element that slides between the two options on a spring
   (stiffness 250, damping 17: a quick slide that overshoots a touch and settles). */
.theme__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--hair), 0 1px 3px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  transform: translateX(0);
  transition: transform 0.65s cubic-bezier(0.34, 1.4, 0.64, 1);
  transition-timing-function: linear(0, 0.037, 0.131, 0.261, 0.408, 0.557, 0.698, 0.823, 0.927, 1.008, 1.068, 1.107, 1.128, 1.135, 1.13, 1.118, 1.101, 1.081, 1.061, 1.042, 1.025, 1.011, 0.999, 0.991, 0.986, 0.983, 0.982, 0.982, 0.984, 0.986, 0.989, 0.992, 0.994, 0.997, 0.998, 1, 1);
}
html[data-theme="dark"] .theme__thumb { transform: translateX(24px); }

/* While the colours fade, elements must not run their own colour transitions on top of it
   (the toggle script adds this class for a moment). The raised circle keeps its slide. */
html.theme-fade *:not(.theme__thumb),
html.theme-fade *:not(.theme__thumb)::before,
html.theme-fade *:not(.theme__thumb)::after {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
  .theme__thumb { transition: none; }
}
.theme__btn:focus-visible { outline: 2px solid var(--muted); outline-offset: 1px; }

/* Work list */

.work { padding-top: 48px; }
.work h2 { font-size: inherit; line-height: inherit; font-weight: inherit; color: var(--muted); padding-bottom: 8px; }

.work__year {
  display: grid;
  grid-template-columns: 104px 1fr;
  border-top: 1px solid var(--hair);
}
.work__yr { color: var(--muted); padding: 10px 0; }

.work__year ul li + li { border-top: 1px solid var(--hair); }

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
}
.row__title { transition: color 0.15s ease; }
.row__company { flex: 0 0 auto; color: var(--muted); }
.row:hover .row__title { color: var(--ink); }

/* ---------- Poster tiles ---------- */

.tile--poster { margin: 0; }
.tile__img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.tile--img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.5) 100%); pointer-events: none; }
.tile__link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.tile__link:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.tile--poster figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px;
  font-size: 14px;
  line-height: 22px;
  color: rgba(255, 255, 255, 0.92);
  pointer-events: none;
  z-index: 1;
}

.tile--p1 {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 40, 0.55) 0 2px, transparent 2px 5px),
    radial-gradient(120% 90% at 50% 20%, #3b4bff 0%, #1d2bd6 55%, #0c147a 100%);
}
.tile--p2 {
  background: linear-gradient(135deg, #ff9f1c 0%, #ff6a3d 42%, #ff3fa4 72%, #b84bff 100%);
}
.tile--p3 {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.75) 100%),
    repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 7px),
    linear-gradient(160deg, #5a5a5a 0%, #262626 55%, #0d0d0d 100%);
}
.tile--p4 { background: linear-gradient(135deg, #0b4f4a 0%, #0f8f84 55%, #2dd4bf 100%); }
.tile--p5 { background: linear-gradient(160deg, #f59e0b 0%, #d9480f 60%, #7c2d12 100%); }
.tile--p6 { background: linear-gradient(150deg, #0ea5e9 0%, #4f46e5 60%, #312e81 100%); }
.tile--p7 { background: linear-gradient(135deg, #15803d 0%, #65a30d 60%, #a16207 100%); }

/* ---------- Links tile ---------- */

.links { height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; }

.links__icons { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.links__icons a {
  display: inline-flex;
  align-items: center;
  padding: 12px;
  margin: -12px;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}
.links__icons a:hover { opacity: 1; }
.links__icons svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.links__cv { font-size: 14px; line-height: 20px; font-weight: 500; }

.links__note { font-size: 14px; line-height: 22px; color: var(--muted); max-width: 30ch; overflow-wrap: anywhere; }
.links__note .basic-link { color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  .tile { animation: none; opacity: 1; }
}
