/*
 * Copyright (C) 2026-Present ComiCine
 * SPDX-License-Identifier: AGPL-3.0-or-later
 * Section 7 additional terms apply when the work is used under GNU AGPL v3.
 * See ADDITIONAL_TERMS.txt.
 */

/*
   Home page styles: stacked-page transitions, flash animation, and portfolio grid.
   */

/* Stack the home and portfolio pages and switch between them with transform. */
.page-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg) !important;
    display: flex; flex-direction: column;
    transition: transform 500ms var(--ease-out), opacity 500ms var(--ease-out);
}

#portfolio {
    z-index: 10; opacity: 0; visibility: hidden; overflow-y: auto;
}

/* Entrance and exit animation states controlled by JavaScript. */
.reveal-item.exit-up {
    opacity: 0 !important; transform: translateY(-60px) !important;
}
.reveal-item.from-top {
    transform: translateY(-60px) !important; opacity: 0 !important; transition: none !important;
}
.portfolio-exit {
    transform: translateY(30px); opacity: 0 !important;
}

/* Portfolio cards: two rows of three with a frame border. */
.work-box {
    background-color: var(--panel-bg);
    border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 10px; /* Frame the image with padding inside the card border. */
    opacity: 0; transform: translateY(20px);
    transition: transform 0.6s var(--ease-out), opacity 0.6s var(--ease-out);
    will-change: transform, opacity; backface-visibility: hidden;
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.work-box.show { opacity: 1; transform: translateY(0); }
.work-box { cursor: pointer; }
.work-box-label {
    font-size: 10px; font-weight: 600; letter-spacing: calc(0.2em*var(--ls-scale)); opacity: 0.2;
}
/* On hover, overlay a gradient and text across the bottom 15% of the image, inside the frame. */
.work-box-hint {
    position: absolute; left: 10px; right: 10px; bottom: 10px;
    height: 15%; /* Use 15% of the card height. */
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600;
    letter-spacing: calc(0.3em*var(--ls-scale)); text-transform: uppercase;
    color: var(--text);
    background: linear-gradient(transparent, var(--image-caption-scrim));
    opacity: 0; transition: opacity 300ms var(--ease-out);
    pointer-events: none; z-index: 2;
}
@media (hover: hover) and (pointer: fine) {
    .work-box:hover .work-box-hint { opacity: 1; color: var(--hover-highlight); }
}
/* Keep the clipping layer radius fixed (outer 16px minus 10px padding), independent of hover.
   The template sets aspect-ratio from each image's dimensions (3:4, 3:2, 2:3, etc.);
   3 / 4 here is only the fallback when no inline value is present. */
.work-frame {
    width: 100%; height: 100%;
    aspect-ratio: 3 / 4;
    border-radius: calc(var(--radius-lg) - 10px);
    overflow: hidden;
}
/* Landscape images such as 3:2 span the full row to preserve their composition. */
.work-box[data-orientation="landscape"] { grid-column: 1 / -1; }
@media (min-width: 640px) {
    .work-box[data-orientation="landscape"] .work-frame { max-width: 840px; margin: 0 auto; }
}
/* The grid defaults to align-items: stretch, which would make portrait cards as tall as the
   tallest card in their row. Align cards by content height so each frame fits its own image. */
.work-box { align-self: start; }
.work-img {
    display: block; width: 100%; height: 100%;
    object-fit: cover;
}
/* Set portfolio image src only after load; hide the empty placeholder to avoid showing alt text. */
.work-img:not([src]) { opacity: 0; }
/* Heading weight. */
h1 { font-weight: 600 !important; }

/* Home page title. */
.hero-title {
    width: 288px;
    aspect-ratio: 1 / 1;
    margin: 0;
}
.hero-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Show or hide the navigation logo based on page state, without a transition. */
#nav-logo.is-hidden { opacity: 0; pointer-events: none; }

/* Hero title. */
#hero-title {
    position: fixed; top: 50%; left: 50%;
    z-index: 150; /* Above the 100px navigation bar so its background does not cover the flight animation. */
    opacity: 0;
    transform: translate(-50%, -40px);
    transition: opacity 200ms ease-out, transform 267ms var(--ease-out);
    white-space: nowrap;
}
#hero-title.visible { opacity: 1; transform: translate(-50%, -50%); }
#hero-title.flying {
    transition: left 267ms var(--ease-out), top 267ms var(--ease-out), transform 267ms var(--ease-out);
}
.hero-closed { pointer-events: none; }

/* Scroll indicator. */
.scroll-hint {
    position: absolute; bottom: 80px; left: 0; right: 0; margin: 0 auto; width: fit-content;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    pointer-events: none;
}
.scroll-hint-inner {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    animation: scroll-bob 2.4s var(--ease-in-out) infinite;
}

.scroll-hint-arrow { width: 35px; height: 35px; }
.scroll-hint span {
    font-size: 12px; letter-spacing: calc(0.12em*var(--ls-scale)); text-transform: uppercase; font-weight: 600;
}
@media (max-width: 767px) {
    .hero-title { width: 144px; }
    .page-layer { height: 100vh; height: 100svh; }
}
@media (max-width: 767px) and (max-height: 700px),
       (orientation: landscape) and (max-height: 520px) {
    .hero-title { width: clamp(96px, 22vh, 128px); }
    .scroll-hint { bottom: calc(24px + env(safe-area-inset-bottom)); }
    .scroll-hint-inner { gap: 4px; }
    .scroll-hint-arrow { width: 28px; height: 28px; }
}
@media (max-width: 767px) and (max-height: 460px),
       (orientation: landscape) and (max-height: 460px) {
    .hero-title { width: 96px; }
    .scroll-hint { bottom: calc(12px + env(safe-area-inset-bottom)); }
    .scroll-hint-arrow { width: 24px; height: 24px; }
}
@media (orientation: landscape) and (max-height: 520px) {
    .page-layer { height: 100vh; height: 100svh; }
}
@keyframes scroll-bob {
    0%, 100% { transform: translateY(0); opacity: 0.25; }
    50% { transform: translateY(6px); opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
    .scroll-hint-inner { animation: none; }
}
