/* ═══════════════════════════════════════════════════════════
   PREMIUM LAYER — loads AFTER style.css. Additive only.
   Uses the existing theme tokens, so all 4 themes still work.
   ═══════════════════════════════════════════════════════════ */

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
::selection { background: var(--accent-primary); color: #fff; }
:focus-visible { outline: 2px solid var(--accent-primary-l); outline-offset: 3px; }

/* Themed slim scrollbar */
html { scrollbar-width: thin; scrollbar-color: var(--accent-primary) transparent; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--grad-superhuman); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* Circular theme-switch reveal (View Transitions API) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

/* Cursor-follow ambient glow */
.pm-glow {
  position: fixed; left: 0; top: 0; width: 520px; height: 520px; margin: -260px 0 0 -260px;
  border-radius: 50%; pointer-events: none; z-index: 1; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(circle, var(--glow-primary) 0%, transparent 65%);
  transition: opacity .6s ease; will-change: transform;
}
.pm-glow.on { opacity: .55; }

/* Word-by-word blur-in headings */
.pm-w { display: inline-block; opacity: 0; filter: blur(14px); transform: translateY(.55em) rotateX(-40deg);
  transition: opacity .8s var(--ease-smooth), filter .8s var(--ease-smooth), transform .9s var(--ease-spring);
  transition-delay: calc(var(--i) * 70ms); }
.pm-in .pm-w { opacity: 1; filter: blur(0); transform: none; }

/* Universal tactile feedback + card glow */
button:active, [class*="btn"]:active { transform: scale(.96); transition: transform .12s ease; }
[class*="card"]:not(.pm-dock *) { transition: box-shadow .5s var(--ease-smooth), border-color .5s ease; }
[class*="card"]:hover { border-color: var(--border-glow); }

/* Floating icon dock */
.pm-dock {
  position: fixed; left: 50%; bottom: 18px; z-index: var(--z-dock); display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px; border-radius: 22px; background: var(--bg-glass-heavy);
  backdrop-filter: var(--glass-blur-heavy); -webkit-backdrop-filter: var(--glass-blur-heavy);
  border: 1px solid var(--border-subtle); box-shadow: var(--glass-shadow), var(--glass-specular);
  transform: translate(-50%, 140%); opacity: 0; transition: transform .9s var(--ease-spring), opacity .6s ease;
}
.pm-dock.show { transform: translate(-50%, 0); opacity: 1; }
.pm-dock a, .pm-dock button {
  --s: 1; position: relative; width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 14px; background: rgba(255,255,255,.04); color: var(--text-secondary); cursor: pointer;
  transform: scale(var(--s)); transform-origin: bottom center; transition: transform .18s ease-out, color .3s, background .3s;
}
/* Each destination owns the accent it represents, so hovering an icon lights up
   that icon in its own colour instead of every one sharing a single hue.
   --dock-hi is the resting colour for the active section and the hover colour;
   the default keeps the old accent behaviour for anything without a tone. */
.pm-dock a, .pm-dock button { --dock-hi: var(--accent-primary-l); }
.pm-dock [data-tone="home"]       { --dock-hi: var(--accent-primary); }
.pm-dock [data-tone="ai"]         { --dock-hi: var(--accent-tertiary); }
.pm-dock [data-tone="services"]   { --dock-hi: var(--accent-secondary); }
.pm-dock [data-tone="projects"]   { --dock-hi: var(--accent-amber); }
.pm-dock [data-tone="skills"]     { --dock-hi: var(--accent-emerald); }
.pm-dock [data-tone="experience"] { --dock-hi: var(--accent-rose); }
.pm-dock [data-tone="contact"]    { --dock-hi: #25D366; }
.pm-dock svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pm-dock a:hover, .pm-dock button:hover {
  color: var(--dock-hi);
  background: rgba(255, 255, 255, 0.1);
  /* tint the fill with that icon's own accent; the plain line above is the
     fallback where color-mix is unsupported */
  background: color-mix(in srgb, var(--dock-hi) 22%, transparent);
}
/* Glow only while hovered: an always-on blur on 8 icons that are already
   re-transformed every frame is wasted GPU. */
.pm-dock a:hover svg, .pm-dock button:hover svg { filter: drop-shadow(0 0 6px currentColor); }
.pm-dock a.active {
  color: var(--dock-hi);
  background: rgba(255, 255, 255, 0.1);
  background: color-mix(in srgb, var(--dock-hi) 16%, transparent);
}
.pm-dock a.active svg { filter: drop-shadow(0 0 5px currentColor); }
.pm-dock a.active::after { content: ""; position: absolute; bottom: -6px; width: 5px; height: 5px; border-radius: 50%; background: var(--dock-hi); box-shadow: 0 0 10px var(--dock-hi); }
.pm-dock [data-tip]::before {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translate(-50%, 6px) scale(calc(1 / var(--s)));
  padding: 4px 10px; font: 500 12px var(--font-sans); white-space: nowrap; color: #fff; border-radius: 8px;
  background: var(--bg-glass-heavy); border: 1px solid var(--border-subtle); opacity: 0; pointer-events: none; transition: .2s;
}
.pm-dock [data-tip]:hover::before { opacity: 1; transform: translate(-50%, 0) scale(calc(1 / var(--s))); }
.pm-dock .pm-sep { width: 1px; height: 28px; align-self: center; background: var(--border-subtle); margin: 0 2px; }
.pm-dock .pm-top svg.ring { position: absolute; inset: 0; width: 44px; height: 44px; transform: rotate(-90deg); stroke-width: 2; stroke: var(--accent-primary-l); }
.pm-dock .pm-top svg.arrow { position: relative; }
@media (max-width: 900px) { .pm-glow { display: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pm-w { opacity: 1; filter: none; transform: none; transition: none; }
  .pm-glow { display: none; }
  /* Content parity: the dock is navigation, not motion. It stays, but every
     transition and the magnify idle state go static so nothing animates. */
  .pm-dock, .pm-dock a, .pm-dock button { transition: none; }
  .pm-dock a, .pm-dock button { --s: 1; }
}

/* ── v2 polish ── */
body { animation: pm-page-in .9s var(--ease-smooth) both; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
@keyframes pm-page-in { from { opacity: 0; } to { opacity: 1; } }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
[data-count], .tc-metric { font-variant-numeric: tabular-nums; }
.section-title { position: relative; }
.section-title::after { content: ""; display: block; width: 0; height: 3px; margin-top: .9rem; border-radius: 3px; background: var(--grad-superhuman); transition: width 1.1s var(--ease-smooth) .35s; }
.section-title.pm-in::after { width: 72px; }
.palette-icon svg { display: block; }
[class*="card"]:hover { transform: translateY(-4px); }
a:not([class]) { text-decoration-color: var(--accent-primary-l); text-underline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { body { animation: none; } .section-title::after { width: 72px; transition: none; } [class*="card"]:hover { transform: none; } }

/* Safe-area for the floating dock (this file loads after style.css, so the
   dock's own inset compensation lives here where it wins the cascade). */
.pm-dock {
  bottom: calc(18px + var(--sab, 0px));
  left: calc(50% + (var(--sal, 0px) - var(--sar, 0px)) / 2);
}

/* ── Mobile / small tablet: the dock becomes a bottom tab bar ──────────
   Content parity: hiding the whole quick-nav below 900px removed 7 section
   links, the active-section indicator and the back-to-top control from every
   phone and small tablet, while the desktop kept them. The mobile paradigm
   replaces a hover-magnify dock with a bottom tab bar -- thumb reachable,
   real 44px targets, no hover tooltips -- so the same destinations stay
   present on every device. This block lives last so it wins the cascade over
   the safe-area `left` above at equal specificity. */
@media (max-width: 900px) {
  .pm-dock {
    left: 0;
    right: 0;
    bottom: 0;
    transform: translateY(0);
    border-radius: 18px 18px 0 0;
    justify-content: safe center;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 10px calc(12px + var(--sar, 0px)) calc(10px + var(--sab, 0px)) calc(12px + var(--sal, 0px));
    gap: 4px;
    max-width: 100%;
  }
  .pm-dock::-webkit-scrollbar { display: none; }
  .pm-dock.show { transform: translateY(0); }
  /* Keep content above the bottom tab bar on mobile */
  body { padding-bottom: calc(64px + var(--sab, 0px)); }
  /* The 1px separator stays: it is 5px wide in total and keeps the desktop
     visual rhythm, so there is no reason to drop it on mobile. It must not
     shrink: in the scrollable tab bar the 44px buttons are flex-shrink:0, and
     without the same guard the 1px rule collapses to a zero rect on the
     narrowest phones and reads as missing content. */
  .pm-dock .pm-sep { flex-shrink: 0; }
  .pm-dock [data-tip]::before { display: none; } /* no hover on touch */
  .pm-dock a, .pm-dock button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    --s: 1;
  }
  /* Lift the two floating controls clear of the tab bar while it is shown,
     so the theme switcher and the Roman AI launcher never sit underneath it.
     `:has` is already used elsewhere in this project for the same purpose. */
  body:has(.pm-dock.show) .theme-spectrum-toggle {
    bottom: calc(88px + var(--sab, 0px));
  }
  body:has(.pm-dock.show) .floating-roman-ai-btn {
    bottom: calc(88px + var(--sab, 0px));
  }
}

/* ── Mobile lite: remove effects that cause lag/hang on phones ──────────── */
@media (max-width: 900px) {
  * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; filter: none !important; }
  .hero-aurora-glow { display: none !important; }
  .backdrop-img { opacity: 0.25; transform: none !important; }
  body::before, body::after { display: none !important; }
  [class*="card"] { transition: none !important; }
  .pm-w { opacity: 1 !important; transform: none !important; }
  .section { padding-left: clamp(16px, 4vw, 32px); padding-right: clamp(16px, 4vw, 32px); }
  .pm-dock [data-tip]::before { display: none; } /* no hover on touch */
  .pm-dock a, .pm-dock button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    --s: 1;
  }
  /* Lift the two floating controls clear of the tab bar while it is shown,
     so the theme switcher and the Roman AI launcher never sit underneath it.
     `:has` is already used elsewhere in this project for the same purpose. */
  body:has(.pm-dock.show) .theme-spectrum-toggle {
    bottom: calc(88px + var(--sab, 0px));
  }
  body:has(.pm-dock.show) .floating-roman-ai-btn {
    bottom: calc(88px + var(--sab, 0px));
  }
}

