/*
File: global.css
Purpose: Shared global styles used by all pages (fonts, base background, and utility classes).
Notes: Peyda is loaded via <link href="assets/fonts/peyda.css"> (from html/: ../assets/fonts/peyda.css).
*/
:root {
    --vvh: 100vh;
    --font-sans: 'PeydaFaNumWeb', Tahoma, sans-serif;
    --default-font-family: 'PeydaFaNumWeb', Tahoma, sans-serif;
    --banner-gap: 16px;
    --banner-side-gap: 16px;
    --topic-accent: #0078d7;
    --banner-fg: #515811;
    --curtain-image: url("../assets/images/bg_curtain.webp");
    --curtain-position: center center;
}
@supports (height: 100dvh) {
    :root { --vvh: 100dvh; }
}
@media (max-width: 767px) {
    :root {
        --curtain-image: url("../assets/images/bg_curtain_mobile.webp");
        --curtain-position: center bottom;
    }
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html.auth-pending body {
    visibility: hidden;
}

@view-transition {
    navigation: auto;
}

/* Keep this after the default so mobile navigation does not capture large snapshots. */
@media (max-width: 767px) {
    @view-transition { navigation: none; }
    html .entry-launch,
    html body.profile-body #profile-main { view-transition-name: none; }
}

::view-transition-group(account-card) {
    animation-duration: 0.7s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

::view-transition-group(entry-dock) {
    animation-duration: 0.7s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

::view-transition-old(entry-dock) {
    animation: vt-dock-out 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

::view-transition-new(entry-dock) {
    animation: vt-dock-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

::view-transition-old(account-card),
::view-transition-new(account-card) {
    animation-duration: 0.55s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes vt-dock-out {
    to { transform: translateY(110%); opacity: 0; }
}

@keyframes vt-dock-in {
    from { transform: translateY(110%); opacity: 0; }
}

html,
body,
button,
input,
select,
textarea {
    font-family: 'PeydaFaNumWeb', Tahoma, sans-serif !important;
}

body {
    background: #f0f4f8;
}

#app-notice {
    position: fixed;
    box-sizing: border-box;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4000;
    max-width: min(440px, calc(100% - 32px));
    padding: 12px 18px;
    border-radius: 12px;
    background: #1b242e;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.6;
    text-align: center;
    box-shadow: 0 10px 24px rgba(27, 36, 46, 0.18);
    direction: rtl;
}
#app-notice[hidden] {
    display: none !important;
}
#app-notice[data-kind="error"] {
    background: #3f2a2a;
}
#app-notice[data-anchored="true"] {
    bottom: auto;
    transform: none;
}

/* Leaflet ships Helvetica/Arial on the map pane; keep Peyda there too. */
.leaflet-container,
.leaflet-popup,
.leaflet-popup-content-wrapper,
.leaflet-popup-content,
.leaflet-tooltip,
.leaflet-control,
.leaflet-bar {
    font-family: 'PeydaFaNumWeb', Tahoma, sans-serif !important;
}

#top-banner {
    position: absolute;
    top: var(--banner-gap);
    left: var(--banner-side-gap);
    right: var(--banner-side-gap);
    width: calc(100% - 2 * var(--banner-side-gap));
    margin: 0;
    height: 75px;
    flex-shrink: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    color: #515811;
    z-index: 2000;
    box-shadow: none;
    border-radius: 12px;
    overflow: visible;
}
#top-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: #ffffff;
    z-index: -1;
    box-shadow: 0 4px 18px rgba(81, 88, 17, 0.08);
    transition: background-color 0.6s ease, box-shadow 0.6s ease;
}
.banner-right { display: flex; align-items: center; gap: 20px; position: relative; }
.banner-left { display: flex; align-items: center; }
.institution { display: flex; align-items: center; gap: 12px; }
#logo-img {
    display: block;
    height: 44px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    cursor: pointer;
}
.banner-divider { width: 2px; height: 42px; background: #a18447; margin: 0 14px; }
.project-texts { display: flex; flex-direction: column; line-height: 1.7; position: relative; flex-shrink: 0; }
.project-main { font-weight: 800; font-size: 0.95rem; color: #515811; }
.project-sub { font-size: 0.8rem; color: #515811; }
.banner-seg {
    display: flex;
    align-items: center;
    margin-inline-start: 18px;
    padding: 0;
    border-radius: 0;
    background: #f7f4ed;
    flex-shrink: 0;
}
.banner-seg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 14px 1px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #515811;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.banner-seg-btn:hover { color: #515811; }
.banner-seg-btn.is-current {
    background: #515811;
    color: #ffffff;
}
.banner-seg-btn.is-current:hover { color: #ffffff; }
.banner-seg-btn[aria-disabled="true"] { cursor: default; }
.user-box { display: flex; align-items: center; gap: 10px; padding-right: 6px; flex-direction: row-reverse; }
.user-menu { position: relative; flex-shrink: 0; overflow: visible; }
.user-circle {
    width: 44px; height: 44px; border-radius: 50%;
    background: #515811;
    border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0; font: inherit; color: #f4eddf;
    appearance: none; -webkit-appearance: none;
    transition: background 0.2s ease;
    overflow: hidden;
    position: relative;
}
.user-circle img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}
.user-circle.has-photo {
    background: #e8eaee;
    border-color: transparent;
}
.user-circle.has-photo img { display: block; }
.user-circle.has-photo svg { display: none; }
.user-circle:hover,
.user-circle.is-open { background: #3f460d; }
.user-circle.has-photo:hover,
.user-circle.has-photo.is-open { background: #e8eaee; }
.user-menu-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    min-width: 12.5rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.18);
    padding: 6px;
    z-index: 5000;
}
.user-menu-dropdown[hidden] { display: none; }
.user-menu-link {
    display: flex; align-items: center; justify-content: flex-start;
    width: 100%; padding: 10px 12px; border-radius: 8px;
    color: #1b242e; font-family: inherit; font-weight: 600; font-size: 0.9rem;
    text-decoration: none; box-sizing: border-box; white-space: nowrap;
}
.user-menu-link:hover { background: #f4f5f7; }
.user-menu-link.is-current { background: #f4f5f7; }
.user-menu-link[hidden] { display: none; }
.user-exit-btn {
    display: flex; align-items: center; justify-content: flex-start; gap: 8px;
    width: 100%; padding: 10px 12px; border: none; background: transparent;
    color: #b91c1c; font-family: inherit; font-weight: 800; font-size: 0.9rem;
    border-radius: 8px; cursor: pointer;
}
.user-exit-btn:hover { background: #fef2f2; }
.user-texts { display: flex; flex-direction: column; line-height: 1.5; text-align: left; }
.user-texts[hidden] { display: none; }
.user-box:not(.is-signed-in) .user-texts { display: none; }
.user-name { font-weight: 800; color: #515811; font-size: 0.95rem; }
.user-role { font-size: 0.75rem; color: #515811; }
.banner-auth-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 36px; padding: 0 14px 1px; border-radius: 999px;
    background: #515811; color: #ffffff;
    text-decoration: none; font-family: inherit; font-weight: 600; font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}
.banner-auth-btn:hover {
    background: #3f460d;
    color: #ffffff;
}
.banner-auth-btn[hidden] { display: none; }



/* Lazy image background utilities */
.lazy-bg { background-size: cover; background-position: center; background-repeat: no-repeat; }
.bg-placeholder { background-color: #f3f4f6; }

/* iPhone / Samsung device preview: keep the desktop design, fit the frame */
@media (max-width: 767px) {
    html, body {
        max-width: 100%;
        overflow-x: hidden;
    }
    input, select, textarea {
        font-size: 16px !important;
    }
    html #top-banner {
        height: 68px;
        min-height: 68px;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-inline-start: 10px;
        padding-inline-end: 12px;
        width: calc(100% - 16px) !important;
        left: 8px !important;
        right: 8px !important;
    }
    html #top-banner .project-sub,
    html #top-banner .user-role,
    html #top-banner .user-name,
    html #top-banner .user-texts {
        display: none !important;
    }
    html #top-banner .banner-divider {
        display: block;
        width: 1.5px;
        height: 38px;
        margin: 0 8px;
        flex-shrink: 0;
    }
    html #top-banner .banner-right {
        gap: 0;
        min-width: 0;
        flex: 1 1 auto;
        flex-wrap: nowrap;
    }
    html #top-banner .banner-left {
        flex: 0 0 auto;
    }
    html #top-banner .institution {
        gap: 0;
        margin-inline-start: 0;
        flex-shrink: 0;
    }
    html #top-banner .project-texts {
        min-width: 0;
    }
    html #top-banner .project-main {
        font-size: 0.78rem;
        line-height: 1.35;
        white-space: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        max-width: 8.4rem;
    }
    html #top-banner .banner-seg {
        margin-inline-start: 4px;
        padding: 0;
        flex-shrink: 1;
        min-width: 0;
    }
    html #top-banner .banner-seg-btn {
        height: 26px;
        padding: 0 7px 1px;
        font-size: 0.68rem;
    }
    html #top-banner .user-box {
        gap: 8px;
    }
    html #top-banner .user-circle {
        width: 34px;
        height: 34px;
    }
    html #top-banner .user-circle svg {
        width: 16px;
        height: 16px;
    }
    html #top-banner .banner-auth-btn {
        display: none !important;
    }
    html #top-banner .user-name {
        font-size: 0.72rem;
        max-width: 5.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    html #top-banner #logo-img {
        height: 40px !important;
    }

    html.atlas-view #top-banner,
    html body.explorer-body #top-banner {
        height: auto;
        min-height: 52px;
        padding: 6px 10px;
        padding-top: max(6px, env(safe-area-inset-top, 0px));
        border-radius: 18px;
        gap: 8px;
    }
    html.atlas-view #top-banner .banner-auth-btn,
    html body.explorer-body #top-banner .banner-auth-btn {
        display: none !important;
    }
    html.atlas-view #top-banner .banner-right,
    html body.explorer-body #top-banner .banner-right {
        flex: 1 1 auto;
        min-width: 0;
    }
    html.atlas-view #top-banner .project-texts,
    html body.explorer-body #top-banner .project-texts {
        display: flex !important;
        min-width: 0;
        flex: 1 1 auto;
        flex-shrink: 1;
    }
    html.atlas-view #top-banner .project-main,
    html body.explorer-body #top-banner .project-main {
        max-width: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        font-size: 0.82rem;
    }
    body.profile-body #top-banner .banner-seg,
    body.profile-body #top-banner .top-nav {
        display: none !important;
    }
    html.atlas-view #top-banner .user-circle,
    html body.explorer-body #top-banner .user-circle {
        width: 40px;
        height: 40px;
    }
    html.atlas-view #top-banner #logo-img,
    html body.explorer-body #top-banner #logo-img {
        height: 36px !important;
    }

    html.atlas-view .page-nav:not([hidden]),
    html body.explorer-body .page-nav:not([hidden]),
    html body.explorer-body #explorer-page-nav:not([hidden]) {
        display: flex;
        flex: 0 0 auto;
        width: calc(100% - 20px);
        margin-left: 10px;
        margin-right: 10px;
        padding: 4px;
        border-radius: 999px;
        background: #ffffff;
        box-shadow: 0 6px 18px rgba(81, 88, 17, 0.08);
        position: relative;
        z-index: 1800;
    }
    html.atlas-view .page-nav:not([hidden]) {
        width: 100%;
        margin: 0;
    }
    html.curtain-auth .page-nav {
        display: none !important;
    }
    .page-nav .banner-seg {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        direction: rtl;
        width: 100%;
        margin: 0;
        padding: 0;
        background: transparent;
        gap: 0;
    }
    .page-nav .banner-seg-btn {
        flex: none;
        height: clamp(34px, 5.4vw, 40px);
        padding: 0 6px 1px;
        border-radius: 999px;
        font-size: clamp(0.72rem, 3.2vw, 0.88rem);
        font-weight: 700;
        min-width: 0;
        order: 0;
    }
    .page-nav .banner-seg-btn[data-nav="atlas"] { grid-column: 1; }
    .page-nav .banner-seg-btn[data-nav="explorer"] { grid-column: 2; }
    .page-nav .banner-seg-btn[data-nav="index"] { grid-column: 3; }
    .page-nav .banner-seg-btn[data-nav="types"] { grid-column: 4; }
}
