/* ==========================================================================
   After Hours — visual layer v4 (round 6)
   Loaded after theme-v2.css. Adds the illustration backdrop, the card gallery,
   a visual-novel text box, and stronger game-like surfaces.
   ========================================================================== */

:root {
  --glass: rgba(255, 255, 255, .78);
  --glass-2: rgba(255, 255, 255, .9);
  --glass-line: rgba(255, 255, 255, .7);
  --title-grad: linear-gradient(100deg, var(--accent-ink) 0%, var(--accent) 48%, var(--accent-2) 100%);
}

/* ---------- ambient illustration backdrop ---------- */
#ambient {
  position: fixed;
  inset: -40px;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: #eef1fa;
}
#ambient img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(26px) saturate(1.35);
  opacity: 0;
  transform: scale(1.08);
  transition: opacity 2.4s ease, transform 16s linear;
}
#ambient img.on { opacity: .62; transform: scale(1.16); }
#ambient::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 600px at 12% 0%, rgba(255, 255, 255, .78), transparent 70%),
    linear-gradient(180deg, rgba(244, 247, 255, .62) 0%, rgba(240, 244, 253, .76) 55%, rgba(236, 241, 252, .88) 100%);
}
body { background: #eef1fa; }
body::before { z-index: 0; }
html.low-effects #ambient img { filter: blur(18px); transition: none; }

/* ---------- page titles ---------- */
.page-title h1 {
  background: var(--title-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -.02em;
}
.page-eyebrow { color: var(--accent) !important; }

/* glass surfaces everywhere (cards that used to be flat white) */
.ah-toolbar, .ah-agenda, .card, .ah-places, .ah-wall, .ah-gallery,
.phone-list, .contact-panel, .ah-messages > section {
  background: var(--glass) !important;
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--glass-line) !important;
}

.ah-kicker {
  display: block;
  font-size: 10.5px; font-weight: 800; letter-spacing: .38em;
  color: var(--accent);
  margin-bottom: 4px;
}

/* ==========================================================================
   HOME — game cover
   ========================================================================== */
.ah-home { padding-top: 6px; }
.ah-hero {
  min-height: clamp(520px, 70vh, 700px) !important;
  box-shadow: 0 50px 110px -50px color-mix(in srgb, var(--accent) 60%, #070b16), 0 0 0 1px rgba(255, 255, 255, .5) !important;
}
.ah-hero-title {
  font-size: clamp(34px, 4.8vw, 64px) !important;
  background: linear-gradient(100deg, #fff 30%, color-mix(in srgb, var(--accent-2) 75%, #fff) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .45));
}
.ah-hero-actions .primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  color: #fff !important;
  box-shadow: 0 16px 34px -14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .45) !important;
  position: relative; overflow: hidden;
}
.ah-hero-actions .primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-18deg);
  animation: ah-sheen 3.8s ease-in-out 1.2s infinite;
}
@keyframes ah-sheen { 0%, 62% { left: -60%; } 100% { left: 130%; } }

/* tilted card frames behind the cast */
.ah-hero-frames { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.ah-hero-frame {
  position: absolute;
  width: clamp(180px, 20vw, 300px);
  aspect-ratio: 16 / 10;
  padding: 0 !important;
  border-radius: 14px !important;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, .9) !important;
  background: #fff !important;
  box-shadow: 0 24px 50px -18px rgba(0, 0, 0, .6);
  pointer-events: auto;
  opacity: .9;
  transition: opacity .3s, transform .5s var(--ease-out) !important;
  animation: ah-drift 9s ease-in-out infinite;
}
.ah-hero-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ah-hero-frame.f0 { right: 4%; top: 7%; --r: 6deg; animation-delay: -1s; }
.ah-hero-frame.f1 { right: 30%; top: 4%; --r: -5deg; width: clamp(150px, 15vw, 230px); animation-delay: -4s; opacity: .7; }
.ah-hero-frame.f2 { display: none; right: 17%; bottom: 7%; --r: 3deg; width: clamp(140px, 13vw, 200px); animation-delay: -6s; opacity: .55; }
.ah-hero-frame:hover { opacity: 1; z-index: 6; transform: rotate(0) scale(1.06) !important; animation-play-state: paused; }
@keyframes ah-drift {
  0%, 100% { transform: rotate(var(--r)) translateY(0); }
  50% { transform: rotate(calc(var(--r) * .7)) translateY(-10px); }
}
.ah-hero-cast { z-index: 3 !important; }
.ah-hero-cast .character-slot > span { opacity: .92 !important; bottom: -2px !important; }

/* gallery corridor */
.ah-gallery {
  margin-top: 26px;
  padding: 24px 0 20px;
  border-radius: var(--r-xl);
  overflow: hidden;
}
.ah-gallery .ah-section-head { padding: 0 26px 14px; }
.ah-gallery h2 { font-size: clamp(22px, 2.4vw, 30px); }
.ill-wall { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 10px; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.ill-track {
  display: flex; gap: 14px; width: max-content;
  animation: ill-scroll var(--dur, 60s) linear infinite;
}
.ill-track.reverse { animation-direction: reverse; }
.ill-wall:hover .ill-track { animation-play-state: paused; }
@keyframes ill-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ill-card {
  position: relative;
  flex: none;
  width: clamp(200px, 21vw, 300px);
  aspect-ratio: 16 / 9.8;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 16px !important;
  overflow: hidden;
  background: #dfe5f3 !important;
  box-shadow: 0 14px 30px -18px rgba(14, 22, 44, .55);
  transition: transform .45s var(--ease-out), box-shadow .45s !important;
  cursor: pointer;
}
.ill-card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .8s var(--ease-out); }
.ill-card::before {
  content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 0%, transparent);
  transition: box-shadow .3s;
}
.ill-card span {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 22px 12px 8px;
  font-size: 12px; font-weight: 700; color: #fff; text-align: left;
  background: linear-gradient(0deg, rgba(6, 10, 22, .78), transparent);
  opacity: 0; transform: translateY(6px);
  transition: opacity .3s, transform .3s;
}
.ill-card:hover, .ill-card:focus-visible { transform: translateY(-6px) scale(1.03); box-shadow: 0 26px 46px -20px color-mix(in srgb, var(--accent) 70%, #0b1020); }
.ill-card:hover img { transform: scale(1.08); }
.ill-card:hover::before, .ill-card:focus-visible::before { box-shadow: inset 0 0 0 3px var(--accent); }
.ill-card:hover span, .ill-card:focus-visible span { opacity: 1; transform: none; }

/* unit wall tiles: card art cover */
.ah-wall-tile img { filter: saturate(1.15); }

/* lightbox */
.ill-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; gap: 14px;
  align-content: center;
  padding: 4vh 4vw;
  background: rgba(6, 10, 22, .82);
  backdrop-filter: blur(14px);
  animation: ah-fade .25s ease both;
  cursor: zoom-out;
}
.ill-lightbox img {
  max-width: min(1400px, 92vw); max-height: 78vh;
  border-radius: 18px;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9), 0 0 0 3px rgba(255, 255, 255, .85);
  animation: ah-pop .4s var(--ease-out) both;
}
.ill-lightbox-cap { text-align: center; color: #fff; display: grid; gap: 4px; }
.ill-lightbox-cap b { font-size: 16px; }
.ill-lightbox-cap small { color: rgba(255, 255, 255, .6); font-size: 11px; }
.ill-lightbox.out { animation: ah-fade .22s ease reverse both; }

/* ==========================================================================
   CAST — character album cards
   ========================================================================== */
.roster-card {
  background: var(--glass-2) !important;
  border: 1px solid rgba(255, 255, 255, .95) !important;
}
.roster-card::before { display: none; }
.roster-art { overflow: hidden; border-radius: 26px 26px 0 0; }
.roster-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: -2;
  filter: saturate(1.2) blur(1.5px) brightness(1.04);
  transform: scale(1.12);
  transition: transform 1s var(--ease-out), filter .5s;
}
.roster-art::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card-accent, var(--accent)) 22%, rgba(255,255,255,.18)) 0%, rgba(255, 255, 255, .14) 45%, rgba(255, 255, 255, .92) 100%),
    radial-gradient(60% 50% at 50% 62%, rgba(255, 255, 255, .55), transparent 75%);
}
.roster-card:hover .roster-bg { transform: scale(1.2); filter: saturate(1.35) blur(0) brightness(1.05); }
.roster-card .roster-body { position: relative; z-index: 2; }
.roster-card .roster-body b { font-size: 17px; }
.roster-card .roster-body::before {
  content: ""; position: absolute; left: 16px; top: 0; width: 34px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--card-accent, var(--accent)), color-mix(in srgb, var(--card-accent, var(--accent)) 40%, #fff));
}
.roster-unit {
  color: #fff !important;
  background: linear-gradient(135deg, var(--card-accent, var(--accent)), color-mix(in srgb, var(--card-accent, var(--accent)) 60%, #fff)) !important;
  border: 0 !important;
  box-shadow: 0 6px 14px -8px var(--card-accent, var(--accent));
}
.roster-star.on { animation: ah-star .5s var(--ease-out); }
@keyframes ah-star { 0% { transform: scale(.6) rotate(-30deg); } 60% { transform: scale(1.3) rotate(10deg); } 100% { transform: none; } }

.ah-chip { transition: transform var(--fast), background var(--fast), box-shadow var(--fast) !important; }
.ah-chip:hover { transform: translateY(-2px); }
.ah-chip.active {
  background: linear-gradient(135deg, var(--chip), color-mix(in srgb, var(--chip) 55%, #fff)) !important;
  color: #fff !important;
  box-shadow: 0 10px 22px -12px var(--chip) !important;
}
.ah-chip.active i { background: #fff !important; }

.ah-group-banner { min-height: 220px; }
.ah-group-banner img { filter: saturate(1.2); }

/* ==========================================================================
   PROFILE — character archive
   ========================================================================== */
.ah-profile-side > img.ah-profile-bg.is-card {
  filter: blur(2.5px) saturate(1.25) brightness(.78);
  transform: scale(1.08);
}
.ah-profile-main {
  background:
    radial-gradient(500px 260px at 100% 0%, color-mix(in srgb, var(--accent-soft) 90%, transparent), transparent 70%),
    #fff !important;
}
.ah-profile-gallery { margin-bottom: 16px; }
.ah-profile-gallery h4 { font-size: 12px; color: var(--accent-ink); letter-spacing: .12em; margin: 0 0 8px; }
.ill-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ill-thumb {
  position: relative; padding: 0 !important; border: 0 !important;
  border-radius: 14px !important; overflow: hidden;
  aspect-ratio: 16 / 9.8;
  background: var(--accent-soft) !important;
  box-shadow: 0 12px 26px -18px rgba(14, 22, 44, .6);
  cursor: zoom-in;
  transition: transform .4s var(--ease-out), box-shadow .4s !important;
}
.ill-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .8s var(--ease-out); }
.ill-thumb span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 6px;
  font-size: 11.5px; font-weight: 700; color: #fff; text-align: left;
  background: linear-gradient(0deg, rgba(6, 10, 22, .76), transparent);
}
.ill-thumb:hover { transform: translateY(-3px); box-shadow: 0 20px 36px -18px color-mix(in srgb, var(--accent) 70%, #0b1020); }
.ill-thumb:hover img { transform: scale(1.06); }
.ah-tabs button.active { box-shadow: 0 8px 18px -10px var(--accent-glow); }

/* ==========================================================================
   SCENE — name tags sit above heads, never on the feet
   ========================================================================== */
.ah-stage-cast .character-slot > span {
  top: -4px !important;
  bottom: auto !important;
  transform: translate(-50%, -100%) !important;
  opacity: .9 !important;
  font-size: 12px !important;
  font-weight: 700;
  color: #fff;
  padding: 4px 12px !important;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 70%, rgba(8, 14, 26, .6)) !important;
  border: 1px solid rgba(255, 255, 255, .5) !important;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .6);
  transition: opacity .2s, transform .3s var(--ease-out) !important;
}
.ah-stage-cast .ah-actor[data-unit] > span { background: color-mix(in srgb, var(--accent) 72%, rgba(8, 14, 26, .5)) !important; }
.ah-stage-cast .character-slot:hover > span,
.ah-stage-cast .character-slot:focus-visible > span { opacity: 1 !important; transform: translate(-50%, calc(-100% - 4px)) !important; }
.ah-stage-cast .character-slot:active .char-cast { filter: brightness(1.18) drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 70%, transparent)); }
.ah-scene-bg img { animation: ah-breathe 18s ease-in-out infinite alternate; }
@keyframes ah-breathe { from { transform: scale(1.02); } to { transform: scale(1.07) translate3d(-.6%, -.4%, 0); } }
.ah-scene::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(40% 30% at 80% 10%, color-mix(in srgb, var(--accent-2) 30%, transparent), transparent 70%),
    radial-gradient(30% 24% at 12% 20%, rgba(255, 255, 255, .16), transparent 70%);
  mix-blend-mode: screen;
  animation: ah-glow 7s ease-in-out infinite alternate;
}
@keyframes ah-glow { from { opacity: .55; } to { opacity: 1; } }

/* ==========================================================================
   NOVEL — visual-novel framing: big cast, one-height text box, floating choices
   ========================================================================== */
.novel-cast { top: 6% !important; bottom: -16% !important; left: 8% !important; right: 8% !important; inset: 6% 8% -16% 8% !important; }
.novel-cast .character-slot > span { display: none !important; }
.novel-cast .character-slot { transition: filter .35s var(--ease), transform .45s var(--ease-out), opacity .35s !important; }
.novel-cast .character-slot:not(.speaking) { filter: brightness(.7) saturate(.85) !important; transform: translateY(10px) scale(.98); }
.novel-cast .character-slot.speaking { transform: translateY(-6px) !important; }
.novel-textbox {
  left: 50% !important; right: auto !important;
  width: min(1180px, calc(100% - 48px)) !important;
  transform: translateX(-50%);
  bottom: 22px !important;
  max-height: 31% !important;
  overflow: visible !important;
  padding: 26px 30px 14px !important;
  border-radius: 22px !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(247, 249, 255, .94)) !important;
  border: 1px solid rgba(255, 255, 255, .9) !important;
  border-top: 4px solid var(--accent) !important;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .8) !important;
  z-index: 6;
}
.novel-name { position: absolute !important; top: -22px !important; left: 22px; margin: 0 !important; }
.novel-ja { font-size: 19px !important; line-height: 1.65; }
.novel-zh { font-size: 13.5px !important; }
.novel-toolbar { margin-top: 6px; padding-top: 8px; }
.novel-toolbar button { padding: 6px 12px !important; font-size: 12px !important; }
.novel-choices.floating {
  position: absolute;
  left: 0; right: 0; margin: 0 auto;
  top: 30%;
  z-index: 8;
  width: min(620px, calc(100% - 40px));
  display: grid; gap: 12px;
  padding: 0 !important;
  background: transparent !important;
  animation: ah-pop .45s var(--ease-out) both;
}
.novel-choices.floating .story-choice {
  padding: 16px 22px !important;
  font-size: 15.5px !important;
  font-weight: 700;
  border-radius: 16px !important;
  background: linear-gradient(100deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .86)) !important;
  border: 1px solid rgba(255, 255, 255, .9) !important;
  border-left: 5px solid var(--accent) !important;
  box-shadow: 0 20px 44px -18px rgba(0, 0, 0, .75) !important;
  text-align: left;
  backdrop-filter: blur(10px);
}
.novel-choices.floating .story-choice:nth-child(2) { animation-delay: .08s; }
.novel-choices.floating .story-choice:hover { transform: translateX(6px) scale(1.01); background: #fff !important; }
.novel-stage.at-choices .novel-cast { filter: brightness(.82); }
.novel-stage.at-choices::before {
  content: "" !important; position: absolute; inset: 0; z-index: 7;
  background: radial-gradient(60% 40% at 50% 44%, rgba(6, 10, 22, .35), transparent 80%);
  pointer-events: none;
}

/* group chat speaker */
.gchat-cast .character-slot.speaking .char-cast { filter: brightness(1.08) drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 60%, transparent)) !important; }
.gchat-cast .character-slot.speaking > span { opacity: 1 !important; background: var(--accent) !important; }

/* ==========================================================================
   Page transition curtain
   ========================================================================== */
#ah-curtain {
  position: fixed; inset: 0; z-index: 900; pointer-events: none;
  background: linear-gradient(115deg, var(--accent) 0%, var(--accent-2) 60%, #fff 100%);
  clip-path: polygon(0 0, 0 0, -20% 100%, -20% 100%);
}
#ah-curtain.run { animation: ah-wipe .62s cubic-bezier(.7, 0, .2, 1) both; }
@keyframes ah-wipe {
  0% { clip-path: polygon(0 0, 0 0, -20% 100%, -20% 100%); opacity: .9; }
  45% { clip-path: polygon(0 0, 120% 0, 100% 100%, -20% 100%); opacity: .9; }
  100% { clip-path: polygon(120% 0, 120% 0, 100% 100%, 100% 100%); opacity: .9; }
}
.page > * { animation-duration: .6s !important; }

/* buttons: press feedback */
button:active:not(:disabled) { transform: scale(.97); }

/* ==========================================================================
   Phones
   ========================================================================== */
@media (max-width: 860px) {
  .ah-hero-frame.f1, .ah-hero-frame.f2 { display: none; }
  .ah-hero-frame.f0 { width: 130px; right: 10px; top: 10px; opacity: .6; }
  .ill-card { width: 200px; }
  .ah-gallery .ah-section-head { padding: 0 18px 10px; }
  .novel-cast { inset: 10% 2% 20% 2% !important; }
  .novel-textbox { width: calc(100% - 20px) !important; bottom: max(10px, env(safe-area-inset-bottom)) !important; max-height: 38% !important; padding: 22px 16px 10px !important; }
  .novel-ja { font-size: 15.5px !important; }
  .novel-zh { font-size: 12px !important; }
  .novel-choices.floating { top: auto; bottom: calc(min(38%, 330px) + 24px); }
  .novel-choices.floating .story-choice { font-size: 14px !important; padding: 13px 16px !important; }
  .ah-stage-cast .character-slot > span { font-size: 10.5px !important; padding: 3px 8px !important; }
  .ill-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  /* stacked hero shows the full group in two rows */
  .ah-hero-art { height: 400px !important; }
  .ah-hero-cast { height: 400px !important; top: 0 !important; }
}

/* ==========================================================================
   Reduced motion / low effects
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .ill-track, .ah-hero-frame, .ah-scene-bg img, .ah-scene::before, .ah-hero-actions .primary::after { animation: none !important; }
  #ah-curtain { display: none; }
}
html.low-effects .ill-track,
html.low-effects .ah-hero-frame,
html.low-effects .ah-scene-bg img,
html.low-effects .ah-scene::before,
html.low-effects .ah-hero-actions .primary::after { animation: none !important; }
html.low-effects #ah-curtain { display: none; }
html.low-effects .ill-wall { overflow-x: auto; }

/* long lines scroll inside the box instead of growing it */
.novel-reading { max-height: calc(31vh - 96px); overflow-y: auto; }
@media (max-width: 860px) { .novel-reading { max-height: calc(38vh - 96px); } }
