/* Dimorio site: top bar and full-screen menu, shared by every page (index.html and the static pages).
   Tokens come from v4.css. Behaviour in js/menu.js: the overlay opens as a curtain from the right edge (the trigger's side),
   entries develop from faint to white like the story headlines, and the hovered entry plays its pair in the preview. */

/* ---------- top bar ---------- */
.bar-r { display: flex; align-items: center; gap: clamp(14px, 2.2vw, 30px); }
.bar-cta { pointer-events: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: 999px;
  background: var(--volt); color: #fff; font: 600 15px/1 var(--text); text-decoration: none; white-space: nowrap; transition: background .2s; }
.bar-cta:hover { background: var(--volt-deep); }
.bar-cta .s { display: none; }
.menu-btn { pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; margin: 0 -4px 0 0; padding: 0 4px;
  border: 0; background: none; color: inherit; font: 500 16px/1 var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.menu-btn[hidden] { display: none; }
/* both words share one grid cell, so the button keeps the width of the longer one */
.menu-t { display: grid; overflow: hidden; }
.menu-t > span { grid-area: 1 / 1; text-align: right; transition: transform .35s var(--ease), opacity .25s; }
.menu-t > span + span { transform: translateY(110%); opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-t > span:first-child { transform: translateY(-110%); opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-t > span + span { transform: none; opacity: 1; }
.menu-i { position: relative; width: 24px; height: 12px; }
.menu-i i { position: absolute; left: 0; right: 0; top: 0; height: 2px; border-radius: 2px; background: currentColor; transition: transform .35s var(--ease), top .35s var(--ease); }
.menu-i i + i { top: 10px; }
.menu-btn[aria-expanded="true"] .menu-i i { top: 5px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-i i + i { transform: rotate(-45deg); }
.menu-btn:hover .menu-i i:first-child { transform: translateX(-4px); }
.menu-btn[aria-expanded="true"]:hover .menu-i i:first-child { transform: rotate(45deg); }

/* language control (IT / EN): static links to the same page in the other language, current one in full white; js/i18n.js remembers the click */
.lang { pointer-events: auto; display: inline-flex; align-items: center; font: 600 13px/1 var(--text); letter-spacing: .06em; }
.lang > * { display: inline-flex; align-items: center; min-height: 44px; padding: 0 3px; color: inherit; }
.lang > * + *::before { content: '/'; margin-right: 6px; opacity: .4; font-weight: 400; }
.lang a { opacity: .6; text-decoration: none; transition: opacity .2s; }
.lang a:hover, .lang a:focus-visible { opacity: 1; }
.lang a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.lang-on { opacity: 1; }
.lang a:focus-visible { outline-offset: 2px; border-radius: 6px; }

/* the one-line suggestion on the Italian home (js/i18n.js): under the bar, never a redirect */
.lang-hint { position: fixed; z-index: 40; top: calc(78px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: calc(100vw - 2 * var(--gut)); padding: 4px 4px 4px 18px; border-radius: 999px; background: rgba(13, 23, 48, .9); color: var(--mist);
  box-shadow: 0 0 0 1px rgba(169, 179, 199, .22), 0 10px 30px rgba(5, 10, 30, .35); font: 400 14px/1.3 var(--text); animation: lh-in .4s var(--ease) .6s both; }
@supports (backdrop-filter: blur(1px)) { .lang-hint { background: rgba(13, 23, 48, .72); backdrop-filter: blur(12px); } }
@keyframes lh-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.lang-hint a { color: var(--paper); font-weight: 600; white-space: nowrap; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.lang-hint button { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--paper); cursor: pointer; }
.lang-hint button:hover { background: rgba(169, 179, 199, .16); }
.lang-hint svg { width: 16px; height: 16px; }
@media (max-width: 479px) { .lang-hint .lh-t { display: none; } .lang-hint { top: calc(70px + env(safe-area-inset-top)); } }
@media (prefers-reduced-motion: reduce) { .lang-hint { animation: none; } }

/* static pages: the bar sits above the ink band and stays on screen; over the white body it turns to paper */
.pg-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) var(--wrap) 14px; background: var(--ink); color: var(--paper);
  transition: background .35s, color .35s, box-shadow .35s; }
.pg-bar.on-paper { background: rgba(255, 255, 255, .97); color: var(--graphite); box-shadow: 0 1px 0 var(--line); }

/* while the menu is open the bar floats over the overlay, always in daylight text */
html.menu-lock { overflow: hidden; }
html.menu-lock body { padding-right: var(--sbw, 0px); }
.menu-on .nav, .menu-on .nav.on-paper, .menu-on .pg-bar, .menu-on .pg-bar.on-paper { z-index: 50; color: var(--paper); background: transparent; box-shadow: none; }
.menu-on .nav { padding-right: calc(var(--gut) + var(--sbw, 0px)); }

@media (max-width: 599px) {
  .bar-cta { padding: 0 16px; }
  .bar-cta .l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bar-cta .s { display: inline; }
  .menu-btn { gap: 10px; }
  .bar-r { gap: 12px; }
  .lang { letter-spacing: .03em; }
}
/* phones: only the other language's code stays (the switch itself), so the Italian bar fits beside "Prova gratis" */
@media (max-width: 429px) {
  .lang-on, .lang > * + *::before { display: none; }
  .lang a { padding: 0 6px; opacity: .78; }
}

/* ---------- overlay ---------- */
.menu { position: fixed; inset: 0; z-index: 45; visibility: hidden; background: var(--ink); color: var(--paper); overflow: hidden auto; overscroll-behavior: contain; }
.menu-on .menu { visibility: visible; animation: m-in .38s cubic-bezier(.7, 0, .2, 1) both; }
.menu-off .menu { visibility: visible; animation: m-out .32s cubic-bezier(.7, 0, .2, 1) both; }
@keyframes m-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes m-out { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 0 100%); } }
/* the curtain's edge: the same 1 px electric line the hero carries */
.menu-edge { position: fixed; top: 0; bottom: 0; left: 0; z-index: 46; width: 2px; margin-left: -1px; background: var(--volt); box-shadow: 0 0 18px 2px rgba(58, 87, 255, .55);
  visibility: hidden; pointer-events: none; transform: translateX(100vw); }
.menu-on .menu-edge { visibility: visible; animation: e-in .38s cubic-bezier(.7, 0, .2, 1) both; }
.menu-off .menu-edge { visibility: visible; animation: e-out .32s cubic-bezier(.7, 0, .2, 1) both; }
@keyframes e-in { 0% { transform: translateX(100vw); opacity: 1; } 85% { opacity: 1; } 100% { transform: translateX(0); opacity: 0; } }
@keyframes e-out { 0% { transform: translateX(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateX(100vw); opacity: 1; } }

.menu-in { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); column-gap: clamp(32px, 5vw, 96px);
  padding: calc(92px + env(safe-area-inset-top)) var(--gut) clamp(28px, 5vh, 56px); }
.pg .menu-in { padding-left: var(--wrap); padding-right: var(--wrap); } /* static pages: line up with their bar */
.menu-nav { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-a { display: flex; align-items: center; gap: 16px; padding: .06em 0; color: var(--paper); text-decoration: none; -webkit-tap-highlight-color: transparent;
  font: 620 clamp(40px, min(6vw, 10.2vh), 100px)/.98 var(--display); font-variation-settings: 'wdth' 80; letter-spacing: -.028em;
  transition: font-variation-settings .5s var(--ease), font-weight .5s var(--ease); }
.menu-a:focus-visible { outline-offset: 4px; border-radius: 8px; }
.menu-on .menu-a { animation: a-in .36s var(--ease) both; animation-delay: calc(70ms + var(--i, 0) * 34ms); }
@keyframes a-in { from { opacity: 0; transform: translate3d(7vw, 0, 0); } to { opacity: 1; transform: none; } }
/* the word: a faint copy and a white copy; the white one is revealed left to right, as in the story headlines */
.menu-w { position: relative; display: block; white-space: nowrap; }
.menu-w .w-b { display: block; }
.menu-w .w-t { position: absolute; inset: 0; color: var(--paper); clip-path: inset(-.2em 100% -.2em 0); transition: clip-path .55s var(--ease); }
.menu-th { display: none; }
.menu-a[aria-current] .menu-w::after { content: ''; position: absolute; left: calc(100% + .22em); top: 50%; width: .14em; height: .14em; margin-top: -.02em; border-radius: 50%; background: var(--volt); }
.menu-quiet { margin: clamp(22px, 4vh, 40px) 0 0; font-size: 16px; color: var(--mist); }
.menu-quiet a { color: var(--paper); font-weight: 500; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.menu-quiet a:hover { text-decoration-thickness: 2px; }

/* ---------- desktop: kinetic list and live preview ---------- */
@media (min-width: 900px) {
  /* the type is sized by its own column, so the widest entry at full width never reaches the preview */
  .menu-nav { container-type: inline-size; }
  .menu-a { font-size: clamp(40px, min(13cqi, 10.2vh), 104px); }
  .menu-w .w-b { color: rgba(169, 179, 199, .4); transition: color .4s; }
  .menu-a.on { font-weight: 660; font-variation-settings: 'wdth' 104; }
  .menu-a.on .w-t { clip-path: inset(-.2em 0 -.2em 0); }
  .menu-pv { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
  .menu-on .menu-pv { animation: pv-in .5s var(--ease) .12s both; }
  @keyframes pv-in { from { opacity: 0; transform: translate3d(4vw, 0, 0); } to { opacity: 1; transform: none; } }
  .pv-frame { position: relative; width: 100%; max-height: 64vh; aspect-ratio: 4 / 3; border-radius: 18px; overflow: hidden; background: #1B2747; }
  .pv-f { position: absolute; inset: 0; opacity: 0; transition: opacity .45s var(--ease); }
  .pv-f.on { opacity: 1; }
  .pv-f img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
  .pv-a { clip-path: inset(0 0 0 88%); }
  .pv-line { position: absolute; top: 0; bottom: 0; left: 88%; width: 2px; margin-left: -1px; background: var(--paper); box-shadow: 0 0 0 1px rgba(58, 87, 255, .55); }
  /* slow automatic sweep: mostly before, across to mostly after, and back */
  .pv-f.on .pv-a { animation: pv-sweep 7s cubic-bezier(.45, 0, .25, 1) .2s infinite; }
  .pv-f.on .pv-line { animation: pv-line 7s cubic-bezier(.45, 0, .25, 1) .2s infinite; }
  @keyframes pv-sweep { 0%, 100% { clip-path: inset(0 0 0 88%); } 50% { clip-path: inset(0 0 0 12%); } }
  @keyframes pv-line { 0%, 100% { left: 88%; } 50% { left: 12%; } }
  .pv-say { margin: 18px 0 0; min-height: 3.3em; max-width: 46ch; }
  .pv-d { display: block; font-size: 19px; line-height: 1.4; color: var(--paper); }
  .pv-c { display: block; margin-top: 4px; font-size: 14px; line-height: 1.45; color: var(--mist); }
}

/* ---------- phone and narrow screens: stacked entries with a thumbnail ---------- */
@media (max-width: 899px) {
  .menu-in { display: flex; flex-direction: column; padding-top: calc(84px + env(safe-area-inset-top)); }
  .menu-nav { flex: 1; justify-content: flex-start; }
  .menu-pv { display: none; }
  .menu-list li + li { border-top: 1px solid rgba(169, 179, 199, .16); }
  .menu-a { gap: 16px; padding: 12px 0; font-size: clamp(34px, 9.6vw, 56px); }
  .menu-w .w-t { display: none; }
  .menu-th { display: block; flex: none; width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: #1B2747; }
  .menu-a:active .menu-w { color: var(--mist); }
}
@media (max-width: 899px) and (max-height: 640px) { .menu-a { padding: 7px 0; font-size: 32px; } .menu-th { width: 40px; height: 40px; } }

/* ---------- reduced motion: a plain fade, no curtain, no sweep ---------- */
@media (prefers-reduced-motion: reduce) {
  .menu-on .menu { animation: m-fade .2s linear both; }
  .menu-off .menu { animation: m-fade .2s linear reverse both; }
  @keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
  .menu-edge { display: none; }
  .menu-on .menu-a, .menu-on .menu-pv { animation: none; }
  .menu-a, .menu-w .w-t, .menu-w .w-b, .pv-f, .menu-t > span, .menu-i i { transition: none; }
  .pv-f.on .pv-a, .pv-f.on .pv-line { animation: none; }
  .pv-a { clip-path: inset(0 0 0 50%); }
  .pv-line { left: 50%; }
}
