/* mahadi.cloud
   Palette from the three-phase colour code (red, yellow, blue) plus black, white and brass.
   The page changes theme section by section; with JS the whole page morphs between them. */

@property --bg     { syntax: "<color>"; inherits: true; initial-value: #000; }
@property --ink    { syntax: "<color>"; inherits: true; initial-value: #fff; }
@property --soft   { syntax: "<color>"; inherits: true; initial-value: #b8b8b8; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: #f2b90f; }
@property --hot    { syntax: "<color>"; inherits: true; initial-value: #e5322d; }
@property --rule   { syntax: "<color>"; inherits: true; initial-value: #2b2b2b; }
@property --on     { syntax: "<color>"; inherits: true; initial-value: #000; }

:root {
  --red: #d7262e;
  --gold: #f2b90f;
  --brass: #c9972b;
  --blue: #1f4bd8;
  --sky: #6d95ff;
  --measure: 64ch;
  /* instrument panels: always black, whatever the section */
  --i-bg: #000;
  --i-ink: #fff;
  --i-soft: #a8a8a8;
  --i-rule: #2e2e2e;
  --i-off: #474747;
}

/* themes. Without JS each section carries its own; with JS only <body> does, and morphs. */
body[data-theme="night"], html:not(.js) [data-theme="night"] {
  --bg: #000; --ink: #fff; --soft: #b8b8b8; --accent: #f2b90f; --hot: #ff4a44; --rule: #2b2b2b; --on: #000;
}
body[data-theme="sun"], html:not(.js) [data-theme="sun"] {
  --bg: #f2b90f; --ink: #000; --soft: #4b3800; --accent: #000; --hot: #b3141b; --rule: #c99700; --on: #f2b90f;
}
body[data-theme="alarm"], html:not(.js) [data-theme="alarm"] {
  --bg: #d7262e; --ink: #fff; --soft: #ffe0de; --accent: #ffd84a; --hot: #ffd84a; --rule: #e8636a; --on: #8a0d13;
}
body[data-theme="paper"], html:not(.js) [data-theme="paper"] {
  --bg: #fff; --ink: #000; --soft: #4f4f4f; --accent: #1f4bd8; --hot: #d7262e; --rule: #e3e3e3; --on: #fff;
}
body[data-theme="blue"], html:not(.js) [data-theme="blue"] {
  --bg: #1f4bd8; --ink: #fff; --soft: #d4defc; --accent: #f2b90f; --hot: #f2b90f; --rule: #5577e4; --on: #000;
}
body[data-theme="tint"], html:not(.js) [data-theme="tint"] {
  --bg: #fff1c7; --ink: #000; --soft: #5a4712; --accent: #d7262e; --hot: #d7262e; --rule: #ead48b; --on: #fff;
}
body[data-theme="china"], html:not(.js) [data-theme="china"] {
  --bg: #a50e15; --ink: #fff; --soft: #f6caca; --accent: #f2b90f; --hot: #f2b90f; --rule: #c63c42; --on: #000;
}
body[data-theme="blush"], html:not(.js) [data-theme="blush"] {
  --bg: #ffe2dc; --ink: #000; --soft: #6a2b26; --accent: #d7262e; --hot: #d7262e; --rule: #f2b3aa; --on: #fff;
}
html:not(.js) section[data-theme] { background: var(--bg); color: var(--ink); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  transition: --bg .9s cubic-bezier(.6,.1,.2,1), --ink .9s, --soft .9s, --accent .9s, --hot .9s, --rule .9s, --on .9s;
}
a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
canvas { display: block; width: 100%; }
::selection { background: var(--gold); color: #000; }

/* scroll progress: three phase-coloured strands */
.progress { position: fixed; inset: 0 0 auto 0; height: 6px; z-index: 30; display: grid; grid-template-rows: repeat(3, 2px); pointer-events: none; }
.progress span { display: block; transform-origin: 0 50%; transform: scaleX(0); }
.progress span:nth-child(1) { background: var(--red); }
.progress span:nth-child(2) { background: var(--gold); }
.progress span:nth-child(3) { background: var(--blue); }

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.95rem max(1.5rem, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--rule); }
.name { color: var(--ink); text-decoration: none; font-weight: 800; font-variation-settings: "wdth" 120; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 1.3rem; flex-wrap: wrap; }
.top nav a { color: var(--soft); text-decoration: none; font-size: 0.92rem; position: relative; }
.top nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 3px; background: var(--accent); transform: scaleX(0); transition: transform .25s; transform-origin: left; }
.top nav a:hover, .top nav a.on { color: var(--ink); }
.top nav a.on::after, .top nav a:hover::after { transform: scaleX(1); }

main { overflow-x: clip; }

/* ---------- hero ---------- */
.hero { position: relative; min-height: calc(100vh - 60px); display: flex; align-items: center; }
.waves { position: absolute; inset: 0; height: 100%; }
.hero-inner { position: relative; max-width: 1180px; margin: 0 auto; padding: 3rem 1.5rem 6rem; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) clamp(240px, 27vw, 370px); gap: clamp(2rem, 4vw, 4rem); align-items: start; }
.hero-text { grid-column: 1; grid-row: 1; }
.hero-who { color: var(--soft); margin: 0 0 1.25rem; }
.hero-title {
  font-size: clamp(3rem, 7.2vw, 6.8rem);
  line-height: 0.9;
  font-weight: 850;
  font-variation-settings: "wdth" 62;
  letter-spacing: -0.02em;
  margin: 0 0 2rem;
  max-width: 10em;
  text-transform: uppercase;
}
.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.04em; }
.hero-title .line + .line { color: transparent; -webkit-text-stroke: 2px var(--gold); }
.lede { font-size: clamp(1.1rem, 1.6vw, 1.3rem); max-width: 34em; margin: 0 0 2rem; }
.hero-meta { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2.25rem; }
.hero-meta p { color: var(--soft); max-width: 30em; margin: 0; }
.freq {
  display: flex; align-items: baseline; gap: 0.3rem;
  padding: 0.45rem 1rem; border-radius: 999px; background: var(--gold); color: #000;
}
.freq-val { font-size: 1.9rem; font-weight: 800; font-variation-settings: "wdth" 75; min-width: 4.2ch; }
.freq-unit { font-weight: 600; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 0.8rem 1.3rem; border: 2px solid var(--ink); border-radius: 999px;
  color: var(--ink); text-decoration: none; font: inherit; font-weight: 700; background: transparent; cursor: pointer;
  transition: background .2s, color .2s, transform .15s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* hero entrance */
.js .hero-who, .js .lede, .js .hero-meta, .js .actions { opacity: 0; }
.js .ready .hero-who { animation: rise .7s .05s both cubic-bezier(.2,.7,.2,1); }
.js .hero-title .line .w { display: inline-block; opacity: 0; }
.js .ready .hero-title .line .w { animation: up .9s both cubic-bezier(.2,.8,.2,1); }
.js .ready .lede { animation: rise .8s .65s both cubic-bezier(.2,.7,.2,1); }
.js .ready .hero-meta { animation: rise .8s .8s both cubic-bezier(.2,.7,.2,1); }
.js .ready .actions { animation: rise .8s .95s both cubic-bezier(.2,.7,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(0.6em); } to { opacity: 1; transform: none; } }
@keyframes up { from { opacity: 0; transform: translateY(105%); } to { opacity: 1; transform: none; } }

/* ---------- sections ---------- */
.block { max-width: 1180px; margin: 0 auto; padding: 7rem 1.5rem; position: relative; }
.head { max-width: 48rem; margin-bottom: 2.75rem; }
h2 {
  font-size: clamp(2.3rem, 5.4vw, 4.4rem);
  line-height: 0.98;
  font-weight: 820;
  font-variation-settings: "wdth" 68;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
  text-wrap: balance;
}
/* light sections get the wide cut, dark ones the condensed cut */
#research h2, #education h2, #projects h2 { font-variation-settings: "wdth" 118; letter-spacing: -0.03em; font-weight: 760; }
#contact h2 { font-variation-settings: "wdth" 62; text-transform: uppercase; font-size: clamp(3rem, 9vw, 7.5rem); line-height: 0.9; }
.head p { color: var(--soft); font-size: 1.12rem; margin: 0; }
h3 { font-size: 1.2rem; margin: 0 0 0.25rem; }
.sub-h { font-size: 1.5rem; font-variation-settings: "wdth" 100; margin: 3.5rem 0 1rem; }
.fine { color: var(--soft); font-size: 0.85rem; max-width: var(--measure); margin-top: 1.25rem; }

/* heading words rise when their section arrives */
.js h2 .w { display: inline-block; opacity: 0; transform: translateY(0.5em); }
.js .in h2 .w, .js h2.in .w { animation: rise .75s both cubic-bezier(.2,.8,.2,1); }

/* reveal */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- instrument panels (always black) ---------- */
.inst {
  background: var(--i-bg); color: var(--i-ink);
  border-radius: 18px; padding: 1.2rem;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.55);
}
.inst .legend { color: var(--i-soft); }

/* day simulator */
.sim { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1.5rem; align-items: start; }
.sim-diagram { margin: 0; }
#day-chart { height: 290px; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-size: 0.85rem; margin-top: 0.6rem; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 0.4rem; }
.sw.load { background: #fff; }
.sw.pv { background: var(--gold); height: 8px; }
.sw.soc { background: var(--sky); }
.sw.out { background: var(--red); height: 8px; opacity: .6; }
.sw.base { background: #8a8a8a; }
.sw.gfm { background: var(--gold); }
.sw.dg { background: #ff4a44; height: 5px; }
.sw.ufls { background: #ff4a44; height: 2px; }
.scrub { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.9rem; }
.scrub output { font-weight: 800; font-size: 1.3rem; min-width: 3.5em; text-align: right; color: var(--gold); }
.play { font: inherit; font-weight: 700; color: #000; background: var(--gold); border: 0; border-radius: 999px; padding: 0.5rem 1.1rem; cursor: pointer; min-width: 5em; }
.play:hover { background: #fff; }
input[type=range] { flex: 1; accent-color: var(--gold); }

.diagram { width: 100%; height: auto; display: block; }
.diagram .bus { stroke: var(--i-rule); stroke-width: 6; stroke-linecap: round; }
.diagram .bus-label { fill: var(--i-soft); font-size: 12px; text-anchor: middle; }
.diagram .node rect { fill: #121212; stroke: #3a3a3a; stroke-width: 1.5; transition: opacity .35s, stroke .35s; }
.diagram .node.key rect { stroke: var(--gold); stroke-width: 2; }
.diagram .node.live rect { stroke: #ff4a44; }
.diagram .node text { fill: #fff; font-size: 14px; font-weight: 600; text-anchor: middle; }
.diagram .node text.sub { fill: var(--i-soft); font-size: 11.5px; font-weight: 400; }
.diagram .node.dead { opacity: 0.3; }
.diagram .path { stroke: var(--i-off); stroke-width: 3; stroke-dasharray: 2 6; transition: stroke .3s; }
.diagram .path.fwd, .diagram .path.rev { stroke: var(--gold); stroke-width: 4; stroke-dasharray: 8 7; stroke-linecap: round; }
.diagram .path.fwd { animation: flow .9s linear infinite; }
.diagram .path.rev { animation: flow .9s linear infinite reverse; }
.diagram .path.dg.fwd { stroke: #ff4a44; }
@keyframes flow { to { stroke-dashoffset: -15; } }
.sim-diagram figcaption { color: var(--i-soft); font-size: 0.95rem; margin-top: 0.6rem; min-height: 3.2em; }
.sim-diagram figcaption.flash { animation: flash .8s; }
@keyframes flash { from { color: var(--gold); } to { color: var(--i-soft); } }

.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 2rem 0 0; }
.tally div { border-top: 3px solid var(--ink); padding-top: 0.6rem; }
.tally dt { color: var(--soft); font-size: 0.9rem; }
.tally dd { margin: 0; font-size: clamp(1.8rem, 3.2vw, 2.6rem); font-weight: 820; font-variation-settings: "wdth" 70; line-height: 1.1; }

/* frequency lab */
.lab { display: grid; grid-template-columns: 0.8fr 1.4fr; gap: 1.5rem; align-items: stretch; }
.lab-controls { display: flex; flex-direction: column; gap: 1.1rem; }
.lab-controls label { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; font-size: 0.95rem; }
.lab-controls label input { grid-column: 1 / -1; }
.lab-controls output { font-weight: 800; color: var(--gold); }
.lab-controls .btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.lab-controls .btn.primary:hover { background: #fff; border-color: #fff; color: #000; }
.readout { margin: 0.4rem 0 0; display: grid; gap: 0.6rem; }
.readout div { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--i-rule); padding-top: 0.5rem; }
.readout dt { color: var(--i-soft); font-size: 0.9rem; }
.readout dd { margin: 0; font-weight: 800; }
.readout dd.bad { color: #ff5a54; }
.readout dd.good { color: var(--gold); }
#freq-chart { height: 360px; }

/* research */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tabs button {
  font: inherit; font-size: 0.98rem; font-weight: 600; color: var(--ink); background: transparent;
  border: 2px solid var(--ink); border-radius: 999px; padding: 0.55rem 1.15rem; cursor: pointer; transition: background .25s, color .25s, border-color .25s;
}
.tabs button:hover { border-color: var(--accent); color: var(--accent); }
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on); }
.panel { padding: 1.6rem 0 0; max-width: var(--measure); animation: panel .45s cubic-bezier(.2,.7,.2,1); }
@keyframes panel { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.eq { font-size: 1.3rem; font-style: italic; color: #fff; background: var(--blue); border-radius: 12px; padding: 0.9rem 1.2rem; display: inline-block; margin: 0 0 1rem; }
.pc { color: var(--soft); }
.pc b { color: var(--ink); }
.gaps { list-style: none; padding: 0; max-width: 60rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; counter-reset: gap; }
.gaps li { border-top: 4px solid var(--hot); padding-top: 0.9rem; counter-increment: gap; }
.gaps li::before { content: counter(gap); display: block; font-size: 2.6rem; font-weight: 850; font-variation-settings: "wdth" 62; color: var(--hot); line-height: 1; margin-bottom: 0.4rem; }
.topic { max-width: var(--measure); background: #000; color: #fff; border-radius: 16px; padding: 1.2rem 1.4rem; margin-top: 2.5rem; border-left: 8px solid var(--gold); }

/* field */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.cols p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; margin: 4rem 0 0; }
.stats div { display: flex; flex-direction: column-reverse; gap: 0.5rem; }
.stats dd { margin: 0; font-size: clamp(2.6rem, 5.6vw, 4.6rem); font-weight: 850; font-variation-settings: "wdth" 62; line-height: 0.95;
  background: linear-gradient(180deg, #ffe07a 0%, var(--gold) 45%, var(--brass) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats dt { color: var(--soft); font-size: 0.92rem; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 0.5rem; bottom: 0.5rem; width: 3px; background: var(--rule); }
.timeline::after { content: ""; position: absolute; left: 7px; top: 0.5rem; width: 3px; height: var(--fill, 0%); background: var(--accent); transition: height .2s linear; }
.timeline > li { position: relative; padding: 0 0 3rem 2.6rem; max-width: 54rem; }
.timeline > li::before {
  content: ""; position: absolute; left: 0; top: 0.35rem; width: 17px; height: 17px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent); z-index: 1;
}
.when { color: var(--accent); font-size: 1.05rem; font-weight: 800; margin: 0 0 0.15rem; }
.timeline h3 { font-size: clamp(1.3rem, 2.4vw, 1.75rem); font-variation-settings: "wdth" 80; line-height: 1.15; }
.role { color: var(--soft); margin: 0 0 0.5rem; }
.timeline p:last-child { margin: 0; max-width: var(--measure); }

/* projects */
.projects { display: grid; gap: 0.9rem; max-width: 54rem; }
.projects details { background: #fff; border-radius: 14px; padding: 0 1.3rem; border-left: 6px solid var(--red); box-shadow: 0 10px 30px -18px rgba(90,60,0,.5); transition: border-color .25s, transform .25s; }
.projects details:hover { transform: translateX(4px); }
.projects details[open] { border-left-color: var(--blue); }
.projects summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.2rem 0; }
.projects summary::-webkit-details-marker { display: none; }
.p-title { font-weight: 750; font-size: 1.15rem; }
.p-tag { color: var(--soft); font-size: 0.88rem; white-space: nowrap; }
.p-tag::after { content: "+"; display: inline-block; margin-left: 0.8rem; color: var(--red); font-size: 1.4rem; font-weight: 700; transition: transform .25s; vertical-align: -2px; }
.projects details[open] .p-tag::after { transform: rotate(45deg); color: var(--blue); }
.projects details p { margin: 0 0 1.3rem; color: #333; max-width: var(--measure); animation: panel .4s; }

/* map */
.map { margin: 0; }
.map figcaption { color: var(--soft); font-size: 0.85rem; margin-top: 0.5rem; text-align: center; }
#china-map { width: 100%; height: auto; display: block; max-width: 980px; margin: 0 auto; }
.grat line { stroke: var(--rule); stroke-width: 1; }
.grat text { fill: var(--soft); font-size: 10px; opacity: .8; }
.route { fill: none; stroke: var(--gold); stroke-width: 2; opacity: .85; }
.city circle.dot { fill: #fff; }
.city circle.ring { fill: none; stroke: #fff; stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: ping 2.4s ease-out infinite; }
.city.home circle.dot { fill: var(--gold); }
.city.home circle.ring { stroke: var(--gold); }
.city text { fill: #fff; font-size: 14px; font-weight: 700; }
.city text.prov { fill: var(--soft); font-size: 10.5px; font-weight: 400; }
.city { cursor: default; outline: none; }
.city.hot text { fill: var(--gold); }
.city:focus-visible circle.dot { stroke: var(--gold); stroke-width: 3; }
@keyframes ping { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }

/* education */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
.two h2 { font-size: clamp(2rem, 3.6vw, 2.9rem); }
.prep { list-style: none; padding: 0; }
.prep li { margin-bottom: 0.55rem; padding-left: 1.4rem; position: relative; }
.prep li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 10px; height: 10px; border-radius: 50%; }
.prep li:nth-child(3n+1)::before { background: var(--red); }
.prep li:nth-child(3n+2)::before { background: var(--gold); }
.prep li:nth-child(3n)::before { background: var(--blue); }

/* contact */
.contact { padding-bottom: 5rem; }
.contact h2 { max-width: 12em; }
.contact > p { font-size: 1.2rem; max-width: 36em; }
.links { list-style: none; padding: 0; margin: 2.4rem 0 0; display: flex; flex-wrap: wrap; gap: 0.8rem; }
.links a { display: inline-block; font-weight: 700; text-decoration: none; background: #000; color: var(--gold); padding: 0.85rem 1.4rem; border-radius: 999px; transition: background .2s, color .2s, transform .2s; }
.links a:hover { background: #fff; color: #000; transform: translateY(-2px); }

footer { max-width: 1180px; margin: 0 auto; padding: 2rem 1.5rem 3rem; color: var(--soft); font-size: 0.85rem; border-top: 2px solid var(--ink); }
footer p { margin: 0.2rem 0; }

/* responsive */
@media (max-width: 900px) {
  .sim, .lab, .cols, .two { grid-template-columns: 1fr; }
  .tally, .stats { grid-template-columns: 1fr 1fr; }
  .gaps { grid-template-columns: 1fr; }
  .top nav { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 1rem; }
  .block { padding: 5rem 1rem; }
  .hero-inner { padding: 3rem 1rem 4rem; }
  .hero-title .line + .line { -webkit-text-stroke-width: 1.5px; }
  #day-chart { height: 230px; }
  #freq-chart { height: 270px; }
  .inst { padding: 0.9rem; border-radius: 14px; }
  .projects summary { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body { transition: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal, .js .hero-who, .js .lede, .js .hero-meta, .js .actions, .js .hero-title .line .w, .js h2 .w { opacity: 1 !important; transform: none !important; }
}
.stats .unit { display: block; margin-top: 0.15em; font-size: 0.42em; font-variation-settings: "wdth" 90; letter-spacing: 0; }

/* ---------- portrait ---------- */
.portrait { grid-column: 2; grid-row: 1; margin: 0; position: relative; align-self: start; }
.portrait-frame { position: relative; z-index: 1; aspect-ratio: 4 / 5; border-radius: 22px; overflow: hidden; background: #1a1a1a; }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.js .portrait-frame { clip-path: inset(100% 0 0 0 round 22px); }
.js .ready .portrait-frame { animation: unveil 1.1s .35s both cubic-bezier(.7,0,.2,1); }
@keyframes unveil { to { clip-path: inset(0 0 0 0 round 22px); } }

/* missing photo: show which file goes here */
.missing { position: relative; }
.missing img { opacity: 0; }
.missing::after {
  content: attr(data-file); position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; text-align: center;
  color: #777; font-size: 0.85rem; background: repeating-linear-gradient(45deg, #161616 0 12px, #1d1d1d 12px 24px);
}

/* ---------- photos ---------- */
.deals { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; }
.ph {
  display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in; background: #1a1a1a;
  border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; position: relative;
  box-shadow: 0 16px 30px -20px rgba(80,0,0,.6);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s;
}
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.ph:hover { transform: translateY(-4px) rotate(-0.6deg); box-shadow: 0 24px 40px -22px rgba(80,0,0,.8); }
.ph:hover img { transform: scale(1.06); }
.deals li:nth-child(even) .ph:hover { transform: translateY(-4px) rotate(0.6deg); }
.ph::before { content: ""; position: absolute; inset: auto 0 0 0; height: 5px; z-index: 1; background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .35s; }
.deals li:nth-child(3n+2) .ph::before { background: var(--gold); }
.deals li:nth-child(3n) .ph::before { background: var(--blue); }
.ph:hover::before, .ph:focus-visible::before { transform: scaleX(1); }
/* tiles deal in one after another when the grid arrives */
.js .deals li { opacity: 0; transform: translateY(18px) scale(.96); }
.js .in .deals li, .js .deals.in li { animation: deal .6s both cubic-bezier(.2,.8,.2,1); }
.deals li:nth-child(1) { animation-delay: .00s !important; } .deals li:nth-child(2) { animation-delay: .07s !important; }
.deals li:nth-child(3) { animation-delay: .14s !important; } .deals li:nth-child(4) { animation-delay: .21s !important; }
.deals li:nth-child(5) { animation-delay: .28s !important; } .deals li:nth-child(6) { animation-delay: .35s !important; }
.deals li:nth-child(7) { animation-delay: .42s !important; } .deals li:nth-child(8) { animation-delay: .49s !important; }
@keyframes deal { to { opacity: 1; transform: none; } }

.moments { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 1.2rem; align-items: start; }
.moments figure { margin: 0; }
.moments figure:first-child .ph { aspect-ratio: 4 / 3.4; }
.moments figcaption { margin-top: 0.7rem; color: var(--soft); font-size: 0.95rem; }
.moments figcaption b { display: block; color: var(--ink); font-size: 1.05rem; }

/* lightbox */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; margin: 0; color: #fff; overflow: hidden; }
.lightbox::backdrop { background: rgba(0,0,0,.92); }
.lightbox[open] { display: grid; place-items: center; grid-template-rows: 1fr auto; animation: lbin .3s both; }
@keyframes lbin { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { max-width: min(92vw, 1400px); max-height: 80vh; object-fit: contain; border-radius: 10px; align-self: end; }
.lb-cap { margin: 1rem 0 2rem; font-size: 1rem; text-align: center; padding: 0 1rem; }
.lightbox button { position: absolute; background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 999px; width: 52px; height: 52px; font-size: 2rem; line-height: 1; cursor: pointer; transition: background .2s, color .2s; }
.lightbox button:hover { background: var(--gold); color: #000; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-close { right: 1rem; top: 1rem; }

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .portrait { grid-column: 1; grid-row: 1; width: min(62vw, 280px); margin-bottom: 1rem; }
  .hero-text { grid-row: 2; }
  .deals { grid-template-columns: repeat(2, 1fr); }
  .moments { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .js .portrait-frame { clip-path: none; }
  .js .deals li { opacity: 1; transform: none; }
}
.prep b { display: block; }
.prep li { margin-bottom: 0.9rem; }
.hero { align-items: flex-start; }
