/* HANDHELD OS — Kai Kitada portfolio
   The viewport is a 2008 portable-player screen: status bar, barrel-curved picture, key bar.
   Palette measured from the reference video: navy / ultramarine / periwinkle / lavender-white + ivory glow. */

:root {
  --navy: #080848;
  --navy-2: #0a0a6e;
  --navy-3: #080898;
  --ultra: #1828d8;
  --ultra-2: #2a3cf0;
  --peri: #9898d8;
  --peri-2: #b8b8d8;
  --lav: #d0d0e8;
  --paper: #e6e6f4;
  --cream: #ecebd0;
  --cream-2: #d8d8c8;
  --ink-soft: #2a2a6a;
  --dark: #03031a;

  --card-a: 0.95;
  --card-dark-a: 0.9;

  --bar-top: 50px;
  --bar-bot: 60px;
  --side: 5px;
  --inset: 0px;
  /* safe areas (viewport-fit=cover: notch / rounded corners / home indicator) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --pic-h: calc(100vh - var(--bar-top) - var(--bar-bot) - var(--sab) - var(--sat));

  --f-ui: "Inter Tight", "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --f-display: "Unbounded", "Inter Tight", "Zen Kaku Gothic New", sans-serif;
  --f-himel: "Syne", "Unbounded", sans-serif; /* the Himel Agent logo's face */
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 0.84, 0.24, 1);
}
html[data-mode="scene"] {
  --bar-top: clamp(46px, 7.2vh, 66px);
  --bar-bot: clamp(56px, 8.4vh, 76px);
  --side: 10px;
  --inset: clamp(0px, 0.7vw, 10px);
  --pic-h: calc(100vh - var(--bar-top) - var(--bar-bot) - var(--sab) - var(--sat));
  scroll-snap-type: y mandatory;
}
@supports (height: 100svh) {
  :root,
  html[data-mode="scene"] {
    --pic-h: calc(100svh - var(--bar-top) - var(--bar-bot) - var(--sab) - var(--sat));
  }
}
/* a scene taller than the picture (short windows; layout.js measures it): free scrolling instead of
   mandatory snapping, which Safari would use to pull the scene's bottom out of reach */
html[data-mode="scene"][data-snap="off"] {
  scroll-snap-type: none;
}
/* short scene-mode windows (e.g. 1366×657 laptops): tighter scene padding so scenes still fit */
@media (min-width: 760px) and (max-height: 720px) {
  html[data-mode="scene"] .scene {
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

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

html {
  background: var(--dark);
  color: var(--navy);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-top) + var(--sat));
  scroll-padding-bottom: calc(var(--bar-bot) + var(--sab));
  scrollbar-color: var(--peri) var(--dark);
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-ui);
  font-size: 16px;
  line-height: 1.75;
  background: var(--dark);
  -webkit-font-smoothing: antialiased;
}
html[lang="ja"] body {
  line-height: 1.85;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd {
  margin: 0;
}
ol,
ul {
  padding: 0;
  list-style: none;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}

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

/* focus: a thick ultramarine ring with a pale halo — visible on every field */
:focus-visible {
  outline: 3px solid var(--ultra-2);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px rgba(230, 230, 244, 0.9);
  border-radius: 4px;
}
[data-tone="dark"] :focus-visible,
.card-dark :focus-visible,
.menu :focus-visible {
  outline-color: var(--paper);
  box-shadow: 0 0 0 7px rgba(42, 60, 240, 0.85);
}
/* headings receive focus programmatically when a scene is reached by keyboard: no ring there */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus,
main[tabindex="-1"]:focus {
  outline: none;
  box-shadow: none;
}

.skip {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 16px;
  background: var(--navy);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  transform: translateY(-200%);
}
.skip:focus {
  transform: none;
}

/* ============================================================ fixed layers */

.gl,
.gl-fallback {
  position: fixed;
  z-index: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: block;
}
@supports (height: 100lvh) {
  .gl,
  .gl-fallback {
    height: 100lvh;
  }
}
.gl {
  background: var(--paper);
}
.gl-fallback {
  display: none;
  background:
    radial-gradient(60% 50% at 50% 18%, rgba(24, 40, 216, 0.85), transparent 70%),
    radial-gradient(70% 60% at 50% 55%, var(--paper) 40%, var(--cream) 62%, var(--lav) 80%);
}
html.no-gl .gl,
html.no-js .gl {
  display: none;
}
html.no-gl .gl-fallback,
html.no-js .gl-fallback,
html.gl-lost .gl-fallback {
  display: block;
}
html.gl-lost .gl {
  visibility: hidden;
}
html:is(.no-gl, .gl-lost)[data-scene="1"] .gl-fallback,
html:is(.no-gl, .gl-lost)[data-scene="4"] .gl-fallback {
  background: radial-gradient(circle at 72% 50%, var(--ultra) 0 14%, var(--navy) 14.5% 22%, var(--navy-3) 22.5% 34%, var(--navy) 34.5% 100%);
}
html:is(.no-gl, .gl-lost)[data-scene="2"] .gl-fallback {
  background:
    radial-gradient(40% 50% at 72% 50%, var(--ultra-2), transparent 70%),
    radial-gradient(80% 80% at 30% 40%, var(--cream), var(--paper) 60%, var(--lav));
}
html:is(.no-gl, .gl-lost)[data-scene="2"][data-work="1"] .gl-fallback {
  background: radial-gradient(circle at 72% 50%, var(--ultra-2) 0 12%, var(--navy) 30%, var(--navy) 100%);
}
html:is(.no-gl, .gl-lost)[data-scene="3"] .gl-fallback {
  background:
    radial-gradient(circle at 12% 50%, var(--paper) 0 42%, var(--ultra) 42.5% 44%, transparent 44.5%),
    repeating-conic-gradient(from 45deg at 50% 50%, var(--peri) 0 25%, var(--paper) 0 50%) 0 0 / 120px 120px;
}

.bezel {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.bezel-sheen {
  opacity: 0.8;
}
.bezel-glow {
  stroke: rgba(236, 235, 208, 0.55);
  stroke-width: 7;
}
.bezel-line {
  stroke: var(--navy);
  stroke-width: 1.6;
}
/* the dark rim around the handheld on big screens */
.edge {
  position: fixed;
  z-index: 40;
  inset: var(--inset);
  border-radius: calc(var(--inset) * 1.4);
  pointer-events: none;
  box-shadow: 0 0 0 1px #15155a, 0 0 0 400px var(--dark);
}
html:not([data-mode="scene"]) .edge {
  display: none;
}

/* ============================================================ status bar */

.status {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--bar-top) + var(--sat));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(var(--inset) + var(--sat)) calc(var(--inset) + max(clamp(12px, 1.6vw, 24px), var(--sar))) 4px
    calc(var(--inset) + max(clamp(12px, 1.6vw, 24px), var(--sal)));
  color: var(--navy);
  pointer-events: none;
}
.status > * {
  pointer-events: auto;
}
.status-l {
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.9vw, 12px);
  min-width: 0;
}
.clock,
.date {
  font: italic 560 clamp(15px, 1.45vw, 21px) / 1 var(--f-ui);
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: skewX(-6deg);
}
.clock-colon {
  display: inline-block;
  animation: colon-breathe 2s ease-in-out infinite;
}
/* the 2008 player set AM/PM smaller than the digits, tucked up to the baseline */
.clock-ap {
  font-size: clamp(10px, 0.62em, 13px);
  letter-spacing: 0.04em;
  opacity: 0.72;
  vertical-align: 0.14em;
  margin-left: 0.1em;
}
@keyframes colon-breathe {
  50% {
    opacity: 0.25;
  }
}
.battery {
  position: relative;
  width: clamp(26px, 2.6vw, 38px);
  height: clamp(13px, 1.25vw, 17px);
  border-radius: 3px;
  background: rgba(8, 8, 72, 0.16);
  box-shadow: inset 0 0 0 1px rgba(8, 8, 72, 0.4);
  flex: none;
}
.battery::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 30%;
  bottom: 30%;
  width: 3px;
  border-radius: 1px 0 0 1px;
  background: var(--navy);
}
.battery-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 20%);
  border-radius: 3px;
  background: var(--navy);
  transition: width 0.45s var(--ease-out);
}
.status-c {
  font: 620 clamp(14px, 1.45vw, 21px) / 1 var(--f-ui);
  letter-spacing: -0.035em;
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44vw;
  font-feature-settings: "tnum" 1;
}
.status-r {
  justify-self: end;
  display: flex;
  gap: clamp(8px, 0.7vw, 10px);
}
.orb {
  position: relative;
  width: clamp(32px, 2.6vw, 38px);
  height: clamp(32px, 2.6vw, 38px);
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--paper);
  background:
    radial-gradient(ellipse 70% 40% at 50% 26%, rgba(152, 152, 216, 0.75), transparent 70%),
    radial-gradient(circle at 50% 60%, #1a24b0 0%, var(--navy-2) 52%, var(--navy) 78%);
  box-shadow:
    inset 0 -2px 3px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.85),
    0 0 0 1px rgba(8, 8, 72, 0.55);
  transition: transform 0.12s, filter 0.12s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.orb::after {
  /* hit area ≥ 40 × 44 px */
  content: "";
  position: absolute;
  inset: -6px -4px;
}
@media (hover: hover) {
  .orb:hover {
    filter: brightness(1.25);
  }
}
.orb:active {
  transform: translateY(1px) scale(0.96);
}
.orb svg {
  grid-area: 1 / 1;
  width: 44%;
  height: 44%;
  fill: currentColor;
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out);
}
.orb-glyph {
  font: 700 12px / 1 var(--f-ui);
  letter-spacing: 0.02em;
  /* keeps the small glyph AA where it crosses the orb's lilac highlight */
  text-shadow: 0 0 2px var(--navy), 0 0 1px var(--navy);
}
.orb .i-play {
  opacity: 0;
  transform: scale(0.8);
}
.orb.is-paused .i-play {
  opacity: 1;
  transform: none;
}
.orb.is-paused .i-pause {
  opacity: 0;
  transform: scale(0.8);
}

/* ============================================================ key bar */

.keys {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--bar-bot) + var(--sab));
  padding: 4px calc(var(--inset) + max(clamp(12px, 1.4vw, 22px), var(--sar))) calc(var(--inset) + var(--sab))
    calc(var(--inset) + max(clamp(10px, 1.2vw, 18px), var(--sal)));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(10px, 2vw, 28px);
  pointer-events: none;
}
.keys > * {
  pointer-events: auto;
}
.keys-l {
  display: flex;
  gap: clamp(6px, 0.7vw, 10px);
}
.key {
  display: inline-flex;
  align-items: center;
  gap: clamp(6px, 0.6vw, 10px);
  height: clamp(40px, 5.2vh, 48px);
  min-width: 44px;
  padding: 0 clamp(11px, 1.1vw, 18px) 0 clamp(6px, 0.6vw, 9px);
  border: 1.5px solid var(--navy);
  border-radius: 5px;
  background: linear-gradient(#f4f4fa, #d8d8ea);
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(8, 8, 72, 0.12), 0 1px 0 rgba(8, 8, 72, 0.3);
  color: var(--navy);
  font: 640 clamp(15px, 1.3vw, 19px) / 1 var(--f-ui);
  letter-spacing: -0.03em;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.keys .key:first-child {
  transform: perspective(240px) rotateY(4deg) rotateZ(0.5deg);
}
@media (hover: hover) {
  .key:hover {
    background: linear-gradient(#fbfbff, #e2e2f2);
  }
}
.key:active,
.key.is-pressed {
  transform: translateY(1px) !important;
  background: linear-gradient(#cfcfe4, #e6e6f4);
  box-shadow: inset 0 2px 3px rgba(8, 8, 72, 0.25);
}
.key-cap {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: clamp(22px, 1.8vw, 26px);
  height: clamp(22px, 1.8vw, 26px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #1b2296, var(--navy) 70%);
  color: var(--paper);
  font: 700 clamp(12px, 0.95vw, 14px) / 1 var(--f-ui);
  letter-spacing: 0;
}
/* press feedback: two rings ping out of the cap (Repeater pulse; kinetic-tracked WAAPI) */
.key-label {
  display: inline-block;
}
.key-ring {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.keys-mid {
  min-width: 0;
  display: grid;
  justify-items: center;
}
.scrub {
  position: relative;
  width: min(100%, 520px);
  height: 3px;
  border-radius: 2px;
  background: rgba(8, 8, 72, 0.18);
}
.scrub-fill {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: var(--navy);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.scrub-ticks i {
  /* keyframe diamonds (AE): hollow ahead, solid once passed; the target pops on the cut's swap */
  position: absolute;
  top: -2px;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 1px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--navy);
  transform: rotate(45deg);
}
.scrub-ticks i.on {
  background: var(--navy);
}
/* the playhead: a needle on a spring with an echo ghost trailing it (chrome.js) */
.scrub-needle,
.scrub-ghost {
  position: absolute;
  left: -1.5px;
  top: -6px;
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--navy);
  will-change: transform;
}
.scrub-ghost {
  background: var(--ultra-2);
  opacity: 0;
}
.date {
  justify-self: end;
  padding-top: 4px;
  transform: skewX(-6deg) rotate(-1deg);
}

/* ============================================================ picture + scenes */

.picture {
  position: relative;
  z-index: 10;
  display: block;
  padding: calc(var(--bar-top) + var(--sat)) max(var(--side), var(--sar)) calc(var(--bar-bot) + var(--sab)) max(var(--side), var(--sal));
  outline: none;
}
html.menu-open .picture,
html.is-booting .picture {
  visibility: hidden;
}
html.menu-open {
  overflow: hidden;
}

.scene {
  position: relative;
  min-height: var(--pic-h);
  display: grid;
  align-content: center;
  padding: clamp(28px, 5vh, 60px) clamp(18px, 4.2vw, 76px) clamp(30px, 5vh, 56px);
  overflow-x: clip;
  scroll-snap-align: start;
}
.scene[data-tone="dark"] {
  color: var(--paper);
}
.scene[data-tone="light"] {
  color: var(--navy);
}
.scene-inner {
  position: relative;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
}
.col {
  width: min(100%, 600px);
}
.scene-skills .col {
  width: min(100%, 760px);
}

/* the wide thin bracketed title, doubled like the reference's {SWITCH}:
   solid thin caps + an outlined echo dropping below + a fainter second echo */
.scene-head {
  position: relative;
  margin-bottom: clamp(14px, 2.4vh, 24px);
}
.big {
  --echo-c: var(--ultra-2);
  --plate-c: var(--paper);
  --big-size: clamp(40px, min(7vw, 10.5vh), 120px);
  position: relative;
  display: inline-block;
  font: 200 var(--big-size) / 0.92 var(--f-display);
  letter-spacing: 0.005em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-left: -0.04em;
  padding-bottom: 0.3em;
  isolation: isolate;
}
.big::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  color: transparent;
  pointer-events: none;
  z-index: -1;
  -webkit-text-stroke: 1.2px var(--echo-c);
  /* the whole outlined word, offset down-right — never cut through a stroke */
  transform: translate(0.05em, 0.13em);
}
[data-tone="light"] .big {
  text-shadow: 0 0 2px rgba(230, 230, 244, 0.95), 0 0 12px rgba(230, 230, 244, 0.85);
}
[data-tone="dark"] .big {
  --echo-c: var(--peri);
  --plate-c: var(--navy);
  text-shadow: 0 0 2px rgba(8, 8, 72, 0.95), 0 0 14px rgba(8, 8, 72, 0.8);
}
/* with JS the word is a small SVG (kinetic.js): a halo, two outline echoes, the thin fill and a
   trace stroke that draws the outlines on (AE Trim Path). Units: font-size 100 in the viewBox. */
.big.is-svg {
  display: block;
  padding-bottom: 0;
  margin-left: calc(var(--big-size) * -0.05);
  text-shadow: none;
}
.big.is-svg::after {
  content: none;
}
.big-svg {
  display: block;
  width: calc(var(--big-size) * var(--bw, 6));
  height: calc(var(--big-size) * var(--bh, 1.2));
  overflow: visible;
  font-size: var(--big-size);
}
.big-svg text {
  font: 200 1em var(--f-display);
}
.big-svg .t {
  fill: currentColor;
}
.big-svg .e,
.big-svg .tr {
  fill: none;
  stroke: var(--echo-c);
  stroke-width: 1.2px;
}
.big-svg .tr {
  stroke: currentColor;
  stroke-linecap: round;
  opacity: 0;
}
.big-svg .e1 {
  transform: translate(0.05em, 0.13em);
}
.big-svg .e2 {
  transform: translate(0.1em, 0.26em);
  opacity: 0;
}
.big-svg .h {
  fill: none;
  stroke: var(--plate-c);
  stroke-width: 6px;
  stroke-linejoin: round;
  opacity: 0.6;
}

/* names that smear in per character, with an Echo ghost trailing (kinetic.js) */
.is-split {
  position: relative;
}
.is-split .ch {
  display: inline-block;
  white-space: pre;
}
.is-split .ghost {
  position: absolute;
  inset: 0;
  color: var(--ultra-2);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  text-shadow: none;
}
[data-tone="dark"] .is-split .ghost {
  color: var(--peri);
}
.is-split .ghost .ch {
  opacity: 0;
}
html.still .is-split .ghost {
  display: none;
}

/* the edit: on a jump the visible scene's blocks cut out before the picture breaks up, and the
   target's stay hidden until the cut's swap frame (scenes.js sets/clears the marks) */
.scene[data-leaving] .rv {
  opacity: 0;
  transform: translateX(10px) skewX(-8deg);
  transition:
    opacity 0.11s linear,
    transform 0.14s cubic-bezier(0.5, 0, 0.9, 0.4);
}
.scene[data-leaving] .rv:nth-child(2) {
  transition-delay: 0.02s;
}
.scene[data-leaving] .rv:nth-child(n + 3) {
  transition-delay: 0.04s;
}
.scene[data-arriving] .rv,
.scene[data-leaving="now"] .rv {
  opacity: 0;
  transition: none;
}
/* phones scrolling through a taller scene: waits out of view until it scrolls in (kinetic.js) */
.kin-wait {
  opacity: 0;
}
html.still .scene[data-leaving] .rv,
html.still .scene[data-arriving] .rv,
html.still .kin-wait {
  opacity: 1;
  transform: none;
}

/* the doubled {WORD} flash (the reference's [SWITCH] cut): flat navy, outlined caps, a second copy
   0.62 em higher, clipped by the picture top. Only ever visible inside a ~0.18 s WAAPI animation. */
.cutword {
  /* over the picture's content (the leaving text), under the bezel and the bars */
  position: fixed;
  z-index: 15;
  top: calc(var(--bar-top) + var(--sat));
  bottom: calc(var(--bar-bot) + var(--sab));
  left: max(var(--side), var(--sal));
  right: max(var(--side), var(--sar));
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background: var(--navy);
}
.cutword span {
  grid-area: 1 / 1;
  font: 200 min(17vw, 26vh) / 0.9 var(--f-display);
  text-transform: uppercase;
  white-space: nowrap;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--paper);
}
.cutword span + span {
  transform: translateY(-0.62em);
  opacity: 0;
}
html.still .cutword {
  display: none;
}
.h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(2px, 0.6vh, 8px);
  font: 650 clamp(17px, 1.5vw, 22px) / 1.3 var(--f-ui);
  letter-spacing: -0.01em;
}
.h2 > span:last-child {
  padding: 1px 8px 2px;
  border-radius: 3px;
  background: var(--plate, rgba(230, 230, 244, 0.92));
}
[data-tone="dark"] .h2 > span:last-child {
  --plate: rgba(8, 8, 72, 0.88);
}
/* lead line: a subtitle plate, so it reads over any picture */
.lead {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px 4px;
  border-radius: 3px;
  background: rgba(230, 230, 244, 0.94);
  color: var(--navy);
  font-size: clamp(15px, 1.1vw, 16px);
  font-weight: 500;
  line-height: 1.5;
}
[data-tone="dark"] .lead {
  background: rgba(8, 8, 72, 0.9);
  color: var(--paper);
}
.card-label {
  font: 500 12px / 1.2 var(--f-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* cards: 2008 OS windows */
.card {
  position: relative;
  padding: clamp(16px, 1.8vw, 26px);
  border: 1.5px solid var(--navy);
  border-radius: 6px;
  background: rgba(230, 230, 244, var(--card-a));
  color: var(--navy);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 4px rgba(230, 230, 244, 0.22),
    0 24px 50px -28px rgba(8, 8, 72, 0.75);
}
.card-dark {
  border-color: var(--peri);
  background: rgba(8, 8, 72, var(--card-dark-a));
  color: var(--paper);
  box-shadow:
    inset 0 1px 0 rgba(152, 152, 216, 0.35),
    0 0 0 4px rgba(8, 8, 72, 0.3),
    0 24px 50px -28px rgba(0, 0, 0, 0.8);
}
.card-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  opacity: 0.9;
}
.card-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.35;
}

/* ============================================================ 1 · top */

/* the cover is three things only: the gooey (kai), the name, one subtitle-plate line */
.scene-top .scene-inner {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(6px, 1.4vh, 14px);
  text-align: center;
}
.wordmark-slot {
  position: relative;
  width: min(100%, 1080px, (100vh - 300px) * 2.6);
  aspect-ratio: 2.6;
  margin: 0 auto;
}
.top-head {
  justify-self: center;
  margin: 0;
  padding: 6px 18px 10px;
  text-align: center;
}
.top-name {
  font: italic 640 clamp(30px, 3.3vw, 50px) / 1.05 var(--f-ui);
  letter-spacing: -0.045em;
  /* the tight italic tracking swallows the word gap; keep "Kai" and "Kitada" apart */
  word-spacing: 0.18em;
  transform: skewX(-6deg);
  transform-origin: 50% 100%;
  text-shadow: 0 0 2px var(--paper), 0 0 14px rgba(230, 230, 244, 0.9);
}
/* kanji: no faux italic, and the Latin name's tight tracking would crush them */
:lang(ja) .top-name {
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.top-line {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px 4px;
  border-radius: 3px;
  background: rgba(230, 230, 244, 0.94);
  font-size: clamp(15px, 1.1vw, 16.5px);
  font-weight: 520;
  line-height: 1.5;
  /* one line; if a narrow screen must wrap it, two even lines rather than one stray word */
  text-wrap: balance;
}
.wordmark-fallback {
  display: none;
}
html.no-gl .wordmark-fallback,
html.no-js .wordmark-fallback,
html.gl-lost .wordmark-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  font: 800 clamp(48px, 13vw, 200px) / 1 var(--f-display);
  letter-spacing: -0.08em;
  color: var(--navy);
  text-shadow: 0 0 18px var(--ultra-2), 0 0 42px rgba(24, 40, 216, 0.6);
  white-space: nowrap;
}

/* ============================================================ 2 · about */

.about-p + .about-p {
  margin-top: 0.6em;
}
.about-p {
  font-size: clamp(15px, 1.15vw, 17px);
}
.facts {
  display: grid;
  margin-top: 18px;
  border-top: 1px solid rgba(152, 152, 216, 0.45);
}
.facts > div {
  display: grid;
  grid-template-columns: 7em 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(152, 152, 216, 0.45);
}
.facts dt {
  font: 500 12.5px / 1.9 var(--f-mono);
  letter-spacing: 0.07em;
  color: var(--peri-2);
  text-transform: uppercase;
}
.facts dd {
  font-weight: 600;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.facts a,
.company a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.ext {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.9em;
}

/* ============================================================ 3 · works (channels) */

.works-grid {
  display: grid;
  grid-template-columns: minmax(0, 600px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(20px, 3vw, 48px);
}
.work-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 4;
  align-self: center;
}
html:is(.no-gl, .no-js, .gl-lost) .work-slot .wordmark-fallback {
  font-size: clamp(30px, 4.4vw, 72px);
  letter-spacing: -0.06em;
}
html:is(.no-gl, .gl-lost)[data-work="1"] .work-slot .wordmark-fallback {
  color: var(--paper);
}
.work-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 10px;
}
.work-tab {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  min-height: 48px;
  padding: 6px 8px;
  border: 1.5px solid var(--navy);
  border-radius: 0;
  background: rgba(230, 230, 244, var(--card-a));
  color: var(--navy);
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: background 0.15s, color 0.15s;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.work-tab + .work-tab {
  margin-left: -1.5px;
}
.work-tab:first-child {
  border-radius: 5px 0 0 5px;
}
.work-tab:last-child {
  border-radius: 0 5px 5px 0;
}
.work-name {
  position: relative;
  z-index: 1;
  font: 500 clamp(17px, 1.5vw, 21px) / 1.1 var(--f-display);
  letter-spacing: -0.01em;
}
.work-tab .work-cat {
  display: none;
}
/* a channel-tuning sweep across the tab that was just selected; below the text, so contrast
   never drops (CSS only; html.still stops it with the other animations) */
.work-tab::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent 0%, rgba(230, 230, 244, 0.28) 50%, transparent 100%);
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}
.work-tab[aria-selected="true"]::after {
  animation: work-sweep 0.44s var(--ease-out);
}
@keyframes work-sweep {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  22% {
    opacity: 0.9;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}
@media (hover: hover) {
  .work-tab:hover {
    background: #f3f3fb;
  }
}
.work-tab:focus-visible {
  box-shadow: 0 0 0 6px rgba(230, 230, 244, 0.9);
}
.work-tab[aria-selected="true"] {
  background: var(--navy);
  color: var(--paper);
  box-shadow: inset 0 1px 0 rgba(152, 152, 216, 0.4), 0 0 0 3px rgba(8, 8, 72, 0.18);
}
.work-panels {
  display: grid;
  gap: 10px;
}
.work-panel {
  position: relative;
  padding: clamp(14px, 1.6vw, 22px) clamp(16px, 1.8vw, 24px) clamp(16px, 1.8vw, 24px);
  border: 1.5px solid var(--navy);
  border-radius: 6px;
  background: rgba(230, 230, 244, 0.96);
  color: var(--navy);
  box-shadow: inset 0 1px 0 #fff, 0 0 0 4px rgba(230, 230, 244, 0.22), 0 24px 50px -28px rgba(8, 8, 72, 0.75);
}
.work-title {
  font: 600 clamp(30px, 3.4vw, 50px) / 1.02 var(--f-display);
  letter-spacing: -0.035em;
}
.f-himel,
html[data-work="1"] .work-slot .wordmark-fallback {
  font-family: var(--f-himel);
  font-weight: 800;
  letter-spacing: 0;
}
.work-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--navy);
  color: var(--paper);
  font: 600 13px / 1.5 var(--f-ui);
}
.work-desc {
  margin-top: 10px;
  font-size: clamp(15px, 1.1vw, 16.5px);
}
html.no-js .work-tabs {
  display: none;
}

/* ============================================================ 4 · skills */

.skills {
  display: grid;
  gap: 5px;
}
.skill {
  display: grid;
  grid-template-columns: minmax(150px, 13em) 1fr;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border: 1.5px solid var(--navy);
  border-radius: 5px;
  background: rgba(230, 230, 244, var(--card-a));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.skill-h {
  font: 650 15px / 1.35 var(--f-ui);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chips li {
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--navy);
  color: var(--paper);
  font: 560 13px / 1.5 var(--f-ui);
  letter-spacing: 0;
  white-space: nowrap;
}
.skill:nth-child(even) .chips li {
  background: var(--ultra);
}

/* ============================================================ 5 · contact */

.mail-addr {
  display: inline-block;
  font: 300 clamp(22px, 2.4vw, 36px) / 1.15 var(--f-display);
  letter-spacing: -0.02em;
  text-decoration: none;
  overflow-wrap: anywhere;
}
@media (hover: hover) {
  .mail-addr:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
  }
}
.mail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: 620 15px / 1 var(--f-ui);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s var(--ease-out);
  touch-action: manipulation;
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
/* the action gets the fill; copy stays the utility */
.card-dark .btn-primary {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--navy);
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
/* copy → check: the check draws itself while the copy glyph fades (contact.js toggles .is-done) */
.btn .i-copy,
.btn .i-check {
  transition: opacity 0.14s var(--ease-out);
}
.btn .i-check {
  opacity: 0;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
}
.card-dark .btn.is-done {
  background: var(--paper);
  color: var(--navy);
}
.card-dark .btn.is-done .i-copy {
  opacity: 0;
}
.card-dark .btn.is-done .i-check {
  opacity: 1;
  stroke-dashoffset: 0;
  transition:
    opacity 0.14s var(--ease-out),
    stroke-dashoffset 0.28s var(--ease-out);
}
@media (hover: hover) {
  .card-dark .btn:hover {
    background: var(--paper);
    color: var(--navy);
  }
  .card-dark .btn-primary:hover {
    background: #f7f7fd;
    color: var(--navy);
  }
}
/* the filled primary keeps a dark ring inside the pale card */
.card-dark .btn-primary:focus-visible {
  outline-color: var(--navy);
}
.card-label-2 {
  margin-top: 22px;
}
.accounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.accounts a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid rgba(152, 152, 216, 0.6);
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, transform 0.12s var(--ease-out);
}
.accounts a:active {
  transform: translateY(1px);
}
@media (hover: hover) {
  .accounts a:hover {
    background: var(--paper);
    color: var(--navy);
  }
  .accounts a:hover .acc-id {
    color: var(--ink-soft);
  }
}
.acc-name {
  font-weight: 650;
}
.acc-id {
  margin-left: auto;
  font: 400 12.5px / 1 var(--f-mono);
  color: var(--peri-2);
}
.ico {
  width: 18px;
  height: 18px;
  flex: none;
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}
.ico-github {
  -webkit-mask-image: url(../icons/github.svg);
  mask-image: url(../icons/github.svg);
}
.ico-x {
  -webkit-mask-image: url(../icons/x.svg);
  mask-image: url(../icons/x.svg);
}
.ico-qiita {
  -webkit-mask-image: url(../icons/qiita.png);
  mask-image: url(../icons/qiita.png);
}
.ico-zenn {
  -webkit-mask-image: url(../icons/zenn.svg);
  mask-image: url(../icons/zenn.svg);
}
.company {
  margin-top: 16px;
  font-size: 15px;
}
.company-k {
  font: 500 12px / 1 var(--f-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-right: 8px;
  color: var(--peri-2);
}
.copyright {
  display: inline-block;
  margin-top: 14px;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(8, 8, 72, 0.9);
  font: 500 12px / 1.2 var(--f-mono);
  letter-spacing: 0.06em;
}

/* ============================================================ menu dialog */

.menu {
  width: min(560px, calc(100vw - 32px));
  /* centred in the picture, never over the status / key bars (landscape phones scroll inside) */
  inset-block: calc(var(--bar-top) + var(--sat)) calc(var(--bar-bot) + var(--sab));
  max-height: calc(100dvh - var(--bar-top) - var(--bar-bot) - var(--sat) - var(--sab) - 16px);
  margin: auto;
  padding: clamp(18px, 2.4vw, 28px);
  border: 1.5px solid var(--peri);
  border-radius: 8px;
  background: var(--navy);
  color: var(--paper);
  box-shadow: 0 0 0 5px rgba(8, 8, 72, 0.4), 0 40px 80px -30px #000;
  overflow: auto;
  isolation: isolate;
}
.menu::backdrop {
  background: rgba(3, 3, 26, 0.35);
}
html.no-gl .menu::backdrop {
  background: rgba(8, 8, 72, 0.9);
}
.menu-head {
  margin-bottom: 12px;
}
.big-sm {
  --echo-c: var(--peri);
  --plate-c: var(--navy);
  --big-size: clamp(36px, 5vw, 60px);
}
.menu-title {
  margin-top: 2px;
  font: 650 15px / 1.3 var(--f-ui);
}
.menu-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 5px;
}
/* the selection cursor: a paper bar that travels between items on a spring (menu.js) */
.menu-cursor {
  position: absolute;
  z-index: 0;
  left: 0;
  top: 0;
  border-radius: 4px;
  background: var(--paper);
  pointer-events: none;
}
.menu-list a {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid rgba(152, 152, 216, 0.55);
  border-radius: 4px;
  text-decoration: none;
  font-weight: 650;
}
.menu-list a[aria-current] .mname::before {
  /* the scene now showing */
  content: "▶";
  margin-right: 6px;
  font-size: 0.6em;
  vertical-align: 0.15em;
}
.menu-list a[data-cur] {
  color: var(--navy);
  border-color: var(--navy);
}
.menu-list a {
  /* the colour flips as the bar arrives (it travels in ~0.1 s) */
  transition: color 0.06s 0.05s, background 0.06s 0.05s, border-color 0.06s 0.05s;
}
.menu-keys {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.menu-keys .key {
  height: 42px;
}

/* ============================================================ still mode: user paused / reduced motion */

html.still *,
html.still *::before,
html.still *::after {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  html.no-js *,
  html.no-js *::before,
  html.no-js *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================ responsive */

/* portrait / narrower screens: works becomes one column, the channel wordmark above the list */
@media (max-width: 1023px), (max-aspect-ratio: 6/5) {
  .works-grid {
    grid-template-columns: minmax(0, 640px);
    justify-content: start;
    gap: 0;
  }
  .scene-works .col {
    display: contents;
  }
  .works-grid > * {
    grid-column: 1;
  }
  .work-slot {
    order: 0;
    width: min(100%, 520px);
    margin: 0 0 6px;
  }
  .scene-works .scene-head {
    order: -1;
  }
  .work-tabs {
    order: 1;
  }
  .work-panels {
    order: 2;
  }
}

/* phones and short windows: natural scrolling, snapped per scene where every scene fits */
html:not([data-mode="scene"]) .scene {
  padding: 36px 14px 40px;
}
html:not([data-mode="scene"]) .scene-inner {
  max-width: 640px;
}
html:not([data-mode="scene"]) .big {
  --big-size: clamp(36px, 12.4vw, 72px);
}
html:not([data-mode="scene"]) .wordmark-slot {
  width: 100%;
  aspect-ratio: 2.1;
}
/* layout.js picks the policy: "page" = one channel per flick (every scene fits the picture),
   "soft" = proximity, so a taller scene (small phones, long English copy, large text) never traps */
html:not([data-mode="scene"])[data-snap="page"] {
  scroll-snap-type: y mandatory;
}
html:not([data-mode="scene"])[data-snap="page"] .scene {
  scroll-snap-stop: always;
}
html:not([data-mode="scene"])[data-snap="soft"] {
  scroll-snap-type: y proximity;
}

/* ── phones: a thumb-first handheld, not a squeezed desktop ── */
@media (max-width: 759px) {
  :root {
    --bar-top: 42px;
    --bar-bot: 58px;
    --side: 4px;
  }
  /* a stable picture: svh already excludes the browser toolbar, and the key bar pads itself with the
     bottom safe area — so the scene height never changes while iOS collapses its toolbar */
  html:not([data-mode="scene"]) {
    --pic-h: calc(100svh - var(--bar-top) - var(--bar-bot) - var(--sat));
  }
  .status {
    gap: 6px;
    padding-left: max(12px, var(--sal));
    padding-right: max(10px, var(--sar));
  }
  .status-c {
    max-width: 38vw;
    font-size: 14px;
  }
  .status-r {
    gap: 6px;
  }
  .orb {
    width: 34px;
    height: 34px;
  }
  .orb::after {
    inset: -5px -3px;
  }
  /* key bar: (B) under the left thumb, (A) under the right, the date and a full-width timeline between */
  .keys {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "b date a"
      "b mid a";
    column-gap: 12px;
    row-gap: 6px;
    padding: 6px max(10px, var(--sar)) calc(6px + var(--sab)) max(10px, var(--sal));
  }
  .keys-l {
    display: contents;
  }
  #keyB {
    grid-area: b;
  }
  #keyA {
    grid-area: a;
  }
  .keys-mid {
    grid-area: mid;
    align-self: start;
    padding: 0 0 6px;
  }
  .scrub {
    width: 100%;
  }
  .date {
    grid-area: date;
    justify-self: center;
    align-self: end;
    padding: 0;
    font-size: 14px;
    transform: skewX(-6deg);
  }
  .key {
    height: 46px;
    padding-right: 11px;
    font-size: 15px;
  }
  .menu {
    transform-origin: 50% 100%;
  }

  /* compact one-screen scenes */
  html:not([data-mode="scene"]) .scene {
    padding: 26px 18px 30px;
  }
  .scene-head {
    margin-bottom: 16px;
  }
  .about-p,
  .work-desc {
    font-size: 16px;
  }
  .card {
    padding: 16px;
  }
  .facts {
    margin-top: 14px;
  }
  .facts > div {
    grid-template-columns: 5em 1fr;
    padding: 6px 0;
  }
  .facts dt {
    font-size: 13px;
  }

  /* cover: the wordmark at the optical centre, the name and one line as a lower-third caption */
  .scene-top .scene-inner {
    grid-template-rows: 1fr auto;
    min-height: calc(var(--pic-h) - 56px);
    align-content: stretch;
    justify-items: stretch;
    text-align: left;
  }
  .scene-top .wordmark-slot {
    width: 100%;
    align-self: center;
  }
  .top-head {
    justify-self: start;
    padding: 0 0 4px;
    text-align: left;
  }
  .top-name {
    font-size: clamp(32px, 9.6vw, 42px);
    transform-origin: 0 100%;
    text-shadow: 0 0 2px rgba(230, 230, 244, 0.95), 0 0 14px rgba(230, 230, 244, 0.9);
  }
  .top-line {
    display: inline;
    padding: 3px 8px;
    font-size: 16px;
    line-height: 2.05;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  /* works: segmented project row + a horizontal swipe track of cards (works.js adds .is-swipe) */
  .scene-works {
    --card-a: 1;
  }
  .work-slot {
    width: 100%;
    aspect-ratio: 3.2;
    margin: 0 0 8px;
  }
  .work-tab {
    min-height: 44px;
    padding: 4px 6px;
  }
  .work-name {
    font-size: 14px;
  }
  .work-title {
    font-size: clamp(26px, 8vw, 34px);
  }
  .work-title.f-himel {
    font-size: clamp(21px, 7vw, 30px);
    white-space: nowrap;
  }
  .work-panels.is-swipe {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    margin-inline: -18px;
    padding-inline: 18px;
    scroll-padding-inline: 18px;
  }
  .work-panels.is-swipe::-webkit-scrollbar {
    display: none;
  }
  .work-panels.is-swipe::after {
    /* room for the last card to snap to the start like the others */
    content: "";
    flex: 0 0 12px;
  }
  .is-swipe > .work-panel {
    flex: 0 0 calc(100% - 22px);
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  /* skills: one window with hairline rows (group name over its chips) */
  .skills {
    gap: 0;
    border: 1.5px solid var(--navy);
    border-radius: 6px;
    background: rgba(230, 230, 244, 0.96);
    overflow: hidden;
  }
  .skill {
    grid-template-columns: 1fr;
    row-gap: 4px;
    min-height: 0;
    padding: 7px 12px 8px;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  .skill + .skill {
    border-top: 1px solid rgba(8, 8, 72, 0.16);
  }
  .skill-h {
    font-size: 14px;
    line-height: 1.3;
  }
  .chips li {
    padding: 1px 8px;
    font-size: 13px;
  }

  /* contact: the address big, two equal buttons, the accounts as a 2 × 2 grid */
  .mail-addr {
    display: block;
    padding: 6px 0;
    font-size: clamp(22px, 6.6vw, 28px);
  }
  .mail-actions .btn {
    flex: 1 1 0;
    justify-content: center;
    padding: 0 8px;
    white-space: nowrap;
    font-size: 14px;
  }
  .accounts {
    grid-template-columns: 1fr 1fr;
  }
  .acc-id {
    /* the same handle everywhere: it stays in the link's name, out of the narrow tile */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}
/* short phones (iPhone SE class, 375×667): a tighter rhythm so scenes still fit one picture */
@media (max-width: 759px) and (max-height: 720px) {
  html:not([data-mode="scene"]) .scene {
    padding: 14px 16px 16px;
  }
  html:not([data-mode="scene"]) .big {
    --big-size: clamp(32px, 10.4vw, 60px);
  }
  .scene-head {
    margin-bottom: 10px;
  }
  .lead {
    margin-top: 4px;
    padding: 2px 8px 3px;
  }
  .scene-top .scene-inner {
    min-height: calc(var(--pic-h) - 30px);
  }
  .card {
    padding: 12px 14px;
  }
  .about-p,
  .work-desc {
    font-size: 15px;
    line-height: 1.7;
  }
  .work-slot {
    aspect-ratio: 4.4;
    margin-bottom: 6px;
  }
  .work-panel {
    padding: 12px 14px 14px;
  }
  .work-title {
    font-size: 26px;
  }
  .work-desc {
    margin-top: 6px;
  }
  .h2 {
    margin-top: 0;
  }
  .skill {
    row-gap: 2px;
    padding: 3px 10px 4px;
  }
  .skill-h {
    font-size: 13px;
  }
  .chips {
    gap: 3px;
  }
  .chips li {
    padding: 0 7px;
    font-size: 12.5px;
    line-height: 1.4;
  }
  .mail-addr {
    padding: 2px 0;
  }
  .accounts a {
    min-height: 44px;
    padding: 6px 10px;
  }
}
/* Japanese copy breaks between phrases, not mid-word (Chromium; others keep the default) */
:lang(ja) :is(.top-line, .about-p, .work-desc, .lead) {
  word-break: auto-phrase;
  text-wrap: pretty;
}
/* With JS, phrase.js puts a <wbr> at each phrase end and lines break only there (all browsers) */
:lang(ja) .phrased {
  word-break: keep-all;
  overflow-wrap: anywhere;
}
@media (max-width: 380px) {
  .key {
    padding-right: 9px;
  }
  .battery {
    display: none;
  }
  .skill {
    padding: 6px 10px 7px;
  }
  .chips li {
    font-size: 12.5px;
  }
  /* keep the cover subtitle on one line on 360-wide Android phones */
  .top-line {
    font-size: 14px;
    letter-spacing: -0.01em;
  }
}

/* touch: standalone text links get a 44 px hit area on the same layout */
@media (pointer: coarse) {
  .company a,
  .facts a {
    display: inline-block;
    padding: 12px 0;
    margin: -12px 0;
  }
}

/* short landscape windows: tighten vertical rhythm so every scene fits one screen */
@media (max-height: 820px) and (min-width: 760px) {
  .scene {
    padding-top: clamp(20px, 3.4vh, 40px);
    padding-bottom: clamp(20px, 3.4vh, 40px);
  }
  .scene-head {
    margin-bottom: 12px;
  }
  .skill {
    min-height: 38px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
  .skills {
    gap: 4px;
  }
  .card {
    padding: 16px 18px;
  }
  .facts {
    margin-top: 12px;
  }
  .facts > div {
    padding: 5px 0;
  }
  .card-label-2 {
    margin-top: 12px;
  }
  .card-label {
    margin-bottom: 8px;
  }
  .accounts a {
    min-height: 44px;
    padding: 5px 10px;
  }
  .copyright {
    margin-top: 8px;
  }
  .mail-actions {
    margin-top: 10px;
  }
  .company {
    margin-top: 10px;
  }
  .lead {
    margin-top: 4px;
  }
  .work-tab {
    min-height: 44px;
    padding-top: 5px;
    padding-bottom: 5px;
  }
}

/* landscape phones: slim bars, keys in the bottom corners, two-column scenes (heading or wordmark
   left, content right) so cover, about and contact fit one screen */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --bar-top: 32px;
    --bar-bot: 44px;
  }
  .orb {
    width: 28px;
    height: 28px;
  }
  .orb::after {
    inset: -8px -6px;
  }
  .orb-glyph {
    font-size: 11px;
  }
  .key {
    position: relative;
    height: 36px;
  }
  .key::after {
    /* 44 px hit area */
    content: "";
    position: absolute;
    inset: -4px 0;
  }
  /* thumb-first here too: (B) under the left thumb, (A) under the right, timeline and date between */
  .keys {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }
  .keys-l {
    display: contents;
  }
  #keyB {
    grid-column: 1;
    grid-row: 1;
  }
  .keys-mid {
    grid-column: 2;
    grid-row: 1;
  }
  .date {
    grid-column: 3;
    grid-row: 1;
  }
  #keyA {
    grid-column: 4;
    grid-row: 1;
  }
  .clock,
  .date {
    font-size: 15px;
  }
  html:not([data-mode="scene"]) .big {
    --big-size: clamp(30px, 11vh, 46px);
  }
  html:not([data-mode="scene"]) .scene {
    /* the picture already keeps clear of the side safe areas (notch) */
    padding: 8px 22px 10px;
  }
  html:not([data-mode="scene"]) .scene-inner {
    max-width: none;
  }
  .scene:not(.scene-works) .col {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    column-gap: 28px;
    align-items: center;
    width: 100%;
  }
  .scene:not(.scene-works) .col > .scene-head {
    grid-column: 1;
    grid-row: 1 / span 3;
    margin: 0;
  }
  .scene:not(.scene-works) .col > :not(.scene-head) {
    grid-column: 2;
  }
  .scene-top .scene-inner {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: center;
    justify-items: start;
    column-gap: 24px;
    text-align: left;
  }
  .scene-top .wordmark-slot {
    width: 100%;
    max-height: calc(100svh - 110px);
  }
  .top-head {
    justify-self: start;
    text-align: left;
    padding: 0;
  }
  .top-name {
    transform-origin: 0 100%;
  }
  .works-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    column-gap: 28px;
    align-items: start;
    max-width: none;
  }
  .scene-works .scene-head {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 6px;
  }
  .works-grid > .work-slot {
    grid-column: 1;
    grid-row: 2 / span 2;
    width: 100%;
    margin: 0;
  }
  .works-grid .work-tabs {
    grid-column: 2;
    grid-row: 1;
  }
  .works-grid .work-panels {
    grid-column: 2;
    grid-row: 2;
  }
  .work-panel {
    padding: 8px 14px 10px;
  }
  .work-title {
    font-size: 26px;
  }
  .work-desc {
    margin-top: 4px;
    line-height: 1.5;
  }
  .skills {
    gap: 2px;
  }
  /* a wider chip column: fewer rows wrap, so the list fits a notched phone's picture too */
  .scene-skills .col {
    grid-template-columns: minmax(0, 0.6fr) minmax(0, 1.4fr);
  }
  .skill {
    grid-template-columns: 9.5em 1fr;
    min-height: 0;
    padding: 1px 10px;
  }
  .skill-h {
    font-size: 13px;
  }
  .chips li {
    padding: 0 7px;
    font-size: 12.5px;
  }
  .work-cat,
  .facts dt {
    font-size: 12.5px;
  }
  .card {
    padding: 10px 14px;
  }
  .mail-actions {
    margin-top: 6px;
  }
  .card-label-2 {
    margin-top: 6px;
  }
  .accounts a {
    min-height: 40px;
    padding: 4px 10px;
  }
  .company,
  .copyright {
    margin-top: 4px;
  }
  .menu {
    padding: 14px 18px;
  }
  .menu .big-sm {
    --big-size: 30px;
  }
  .menu-head {
    margin-bottom: 8px;
  }
  .menu-list {
    grid-template-columns: 1fr 1fr;
  }
  .menu-list a {
    min-height: 44px;
    padding-block: 5px;
  }
}

/* ============================================================ preferences */

@media (prefers-reduced-transparency: reduce) {
  :root {
    --card-a: 1;
    --card-dark-a: 1;
  }
  .lead,
  .top-line,
  .h2 > span:last-child {
    background: var(--paper);
  }
  [data-tone="dark"] .lead,
  [data-tone="dark"] .h2 > span:last-child {
    background: var(--navy);
  }
}
@media (forced-colors: active) {
  .gl,
  .gl-fallback,
  .bezel,
  .edge {
    display: none !important;
  }
  .card,
  .key,
  .work-tab,
  .work-panel,
  .skill,
  .orb,
  .menu {
    border: 1px solid CanvasText;
  }
  .big::after,
  .cutword,
  .big-svg .e,
  .big-svg .h,
  .big-svg .tr,
  .is-split .ghost,
  .menu-cursor,
  .work-tab::after,
  .key-ring,
  .scrub-ghost {
    display: none;
  }
  .big-svg .t {
    fill: CanvasText;
  }
  .wordmark-fallback {
    display: grid !important;
    place-items: center;
    height: 100%;
    font: 800 clamp(48px, 13vw, 200px) / 1 var(--f-display);
    text-shadow: none;
  }
  .work-slot .wordmark-fallback {
    font-size: clamp(32px, 5.5vw, 100px);
  }
  /* shapes drawn with background-color would be forced to Canvas and vanish */
  .ico,
  .battery-fill,
  .scrub-fill {
    forced-color-adjust: none;
    background: CanvasText;
  }
  .status,
  .keys {
    background: Canvas;
  }
  /* never leave the content hidden behind a boot that has no picture to show */
  html.is-booting .picture {
    visibility: visible;
  }
}
@media print {
  .gl,
  .gl-fallback,
  .bezel,
  .edge,
  .status,
  .keys,
  .menu,
  .skip {
    display: none !important;
  }
  body,
  html {
    background: #fff;
  }
  .scene {
    min-height: 0;
    color: #000 !important;
  }
}

/* without JavaScript: plain bars over a readable page, and no buttons that would do nothing */
html.no-js .status,
html.no-js .keys {
  background: var(--paper);
  border-bottom: 1.5px solid var(--navy);
}
html.no-js .keys {
  border-top: 1.5px solid var(--navy);
  border-bottom: 0;
}
html.no-js #copyBtn {
  display: none;
}
html.no-js .status-r,
html.no-js .keys-l,
html.no-js .keys-mid,
html.no-js .clock,
html.no-js .date,
html.no-js .bezel,
html.no-js .edge {
  visibility: hidden;
}
