/* ============================================================
   Interaction layer — cursor, palette, transitions, magnetic FX
   ============================================================ */

/* hide native cursor only when our custom cursor is active and pointer is fine */
@media (hover: hover) and (pointer: fine) {
  html.cursor-on, html.cursor-on body, html.cursor-on a, html.cursor-on button {
    cursor: none;
  }
}

/* =========== Custom cursor =========== */
.cur {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: difference;
  will-change: transform;
}
.cur-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  transition: width 0.18s cubic-bezier(0.4,0,0.2,1),
              height 0.18s cubic-bezier(0.4,0,0.2,1),
              opacity 0.18s;
}
.cur-ring {
  width: 24px; height: 24px;
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.22s cubic-bezier(0.4,0,0.2,1),
              height 0.22s cubic-bezier(0.4,0,0.2,1),
              border-color 0.18s,
              opacity 0.18s;
}
html.cur-hover .cur-dot { width: 0; height: 0; opacity: 0; }
html.cur-hover .cur-ring { width: 34px; height: 34px; border-color: rgba(255,255,255,1); }
html.cur-text .cur-dot { width: 2px; height: 14px; border-radius: 1px; }
html.cur-text .cur-ring { width: 0; height: 0; opacity: 0; }
html.cur-down .cur-ring { width: 20px; height: 20px; }
html.cursor-off .cur { display: none; }
@media (hover: none), (pointer: coarse) { .cur { display: none !important; } }

/* =========== Magnetic + hover-grow base =========== */
.mag {
  display: inline-flex;
  transition: transform 0.28s cubic-bezier(0.2,0.8,0.2,1);
  will-change: transform;
}

/* topnav cell — animated underline / fill */
.topnav .cell {
  position: relative;
  overflow: hidden;
}
.topnav .cell::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px 0;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.28s cubic-bezier(0.2,0.8,0.2,1);
}
.topnav .cell:hover::after { transform: scaleX(1); }

/* =========== Page transition overlay =========== */
.page-fade {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.36s cubic-bezier(0.4,0,0.2,1);
}
html.page-leaving .page-fade { opacity: 1; pointer-events: auto; }

/* on page-load, fade in */
.page-fade.entering { opacity: 1; }
html.ready .page-fade.entering { opacity: 0; }

/* =========== Command palette =========== */
.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 8000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
}
.palette-backdrop.open { opacity: 1; pointer-events: auto; }

.palette {
  width: min(560px, calc(100vw - 32px));
  background: var(--paper);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.04),
    0 30px 80px -20px rgba(0,0,0,0.35),
    0 8px 24px -8px rgba(0,0,0,0.12);
  transform: translateY(-8px) scale(0.985);
  transition: transform 0.22s cubic-bezier(0.2,0.8,0.2,1);
}
.palette-backdrop.open .palette { transform: translateY(0) scale(1); }

.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.palette-input-wrap .glyph {
  width: 14px; height: 14px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.palette-input-wrap .glyph::after {
  content: '';
  position: absolute;
  bottom: -3px; right: -3px;
  width: 6px; height: 1.5px;
  background: var(--muted);
  transform: rotate(45deg);
}
.palette input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: -0.005em;
  padding: 0;
}
.palette input::placeholder { color: var(--muted); }
.palette-kbd {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  background: var(--bg);
}
.palette-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  max-height: 50vh;
  overflow-y: auto;
}
.palette-section {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 20px 6px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.12s;
}
.palette-item:hover, .palette-item.sel {
  background: rgba(10,10,10,0.04);
}
.palette-item .icn {
  width: 18px; height: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.palette-item .meta {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  gap: 4px;
}
.palette-item .meta .k {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}
.palette-empty {
  padding: 20px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.palette-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.palette-footer .row { display: flex; gap: 16px; }
.palette-footer .row span { display: inline-flex; align-items: center; gap: 6px; }
.palette-footer .row span .k {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

/* =========== Shortcut helper card (press ?) =========== */
.shortcut-card {
  position: fixed;
  bottom: 24px;
  left: 28px;
  background: var(--paper);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 11px;
  z-index: 20;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06), 0 12px 30px -16px rgba(0,0,0,0.14);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  min-width: 220px;
}
.shortcut-card.shown { opacity: 1; transform: translateY(0); pointer-events: auto; }
.shortcut-card .k {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  color: var(--ink);
  justify-self: start;
}
.shortcut-card .label { color: var(--muted); }
.shortcut-card .row { display: contents; }
.shortcut-card .header {
  grid-column: 1 / -1;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.shortcut-card .header .dismiss {
  font-size: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.16em;
  padding: 0;
  font-family: inherit;
  text-transform: uppercase;
}

/* =========== Hero text reveal =========== */
.hero-poster h1 .line {
  overflow: hidden;
  display: block;
  /* Room for descenders ('g', 'y') — without this the line's overflow:hidden
     clips the bottom of the 'g' in "Design". */
  padding-bottom: 0.12em;
}
.hero-poster h1 .line .inner {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 0.9s cubic-bezier(0.2,0.8,0.2,1);
  will-change: transform;
}
body.ready .hero-poster h1 .line .inner { transform: translateY(0); }
body.ready .hero-poster h1 .line:nth-child(1) .inner { transition-delay: 0.20s; }
body.ready .hero-poster h1 .line:nth-child(2) .inner { transition-delay: 0.34s; }
body.ready .hero-poster h1 .line:nth-child(3) .inner { transition-delay: 0.48s; }

.hero-poster .preamble,
.hero-poster .sub,
.hero-poster .scroll-hint {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s cubic-bezier(0.2,0.8,0.2,1),
              transform 0.7s cubic-bezier(0.2,0.8,0.2,1);
}
body.ready .hero-poster .preamble { opacity: 1; transform: none; transition-delay: 0.08s; }
body.ready .hero-poster .sub { opacity: 1; transform: none; transition-delay: 0.72s; }
body.ready .hero-poster .scroll-hint { opacity: 0.55; transform: none; transition-delay: 0.92s; }

/* Hero orb: no CSS transition on transform — the scroll handler updates
   --orb-scale every frame, and any easing on top lags behind, restarts on
   each update, and visibly shakes during fast scroll. */
.hscroll .hero-poster.hcard::before {
  transition: none;
}

/* =========== Card subtle tilt on hover (homepage cards) =========== */
.hscroll .hcard {
  transform-origin: center center;
}
@media (hover: hover) and (pointer: fine) {
  .hscroll .hcard:hover {
    /* keep stack, raise shadow */
    box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 36px 80px -28px rgba(0,0,0,0.18);
  }
}

/* =========== Live clock in side widget =========== */
.side-widget .clock {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
}
.side-widget .clock .colon { animation: colonBlink 1s steps(1) infinite; }
@keyframes colonBlink {
  0%, 50% { opacity: 1; }
  50.001%, 100% { opacity: 0.25; }
}

/* =========== Section reveal (about / case pages) =========== */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s cubic-bezier(0.2,0.8,0.2,1),
              transform 0.7s cubic-bezier(0.2,0.8,0.2,1);
}
.reveal.in { opacity: 1; transform: none; }

/* link hover underline expand for body links */
.case-text a, .about-section a, .footer a {
  position: relative;
}

/* small focus halo */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
.topnav .cell:focus-visible { outline-offset: 2px; }

/* hover ring around homepage links */
.home-list li a {
  /* underline handled via text-decoration in main.css; this rule kept only for
     the wipe-out hover effect on the same line */
  transition: opacity 0.2s;
}
.home-list li a:hover {
  opacity: 0.55;
}

/* arrow keys in indicator pulse when scrolling */
.hscroll-hint { transition: opacity 0.25s, transform 0.25s; }
html.scrolling .hscroll-hint { opacity: 0.4; transform: translateX(2px); }
