/* StoryWeb shared shell: one header, navigation, profile menu, and footer. */

[data-site-shell] {
    display: contents;
}

body.site-shell-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
}

body.site-shell-page > main,
body.site-shell-page > .container,
body.site-shell-page > .policy-container,
body.site-shell-page > .contact-container,
body.site-shell-page > .promo-page-container {
    flex: 1 0 auto;
}

.site-shell-header {
    position: relative;
    z-index: 100;
    min-height: 72px;
    border-bottom: 1px solid var(--color-border, #e5dfd3);
    background: var(--color-surface, var(--color-bg-secondary, #fff));
}

.site-shell-header .header-content,
.site-shell-nav .subnav-content,
.site-shell-footer .footer-content {
    width: min(100% - 128px, 1440px);
    margin: 0 auto;
}

.site-shell-header .header-content {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-shell-header .brand-link {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    color: var(--color-text, #1c1917);
    text-decoration: none;
}

.site-shell-header .brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 10px;
    background: var(--color-primary, #16a34a);
    color: var(--color-on-primary, #fff);
}

.site-shell-header .brand-icon {
    width: 20px;
    height: 20px;
}

.site-shell-header .brand-copy {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
}

.site-shell-header .brand-copy h1 {
    min-width: 0;
    margin: 0;
    color: inherit;
    font-family: var(--font-display, var(--font-sans, system-ui, sans-serif));
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
    white-space: nowrap;
}

.site-shell-header .header-actions {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 16px;
}

.site-shell-header #auth-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-shell-header .daily-reward-button,
.site-shell-header .login-btn,
.site-shell-header .user-menu-button {
    font: inherit;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 110ms ease, box-shadow 180ms ease;
}

.site-shell-header .daily-reward-button {
    position: relative;
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid var(--color-danger-border, var(--color-border, #e5dfd3));
    border-radius: 10px;
    background: var(--color-danger-soft, transparent);
    color: var(--color-danger, var(--color-text, #1c1917));
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.site-shell-header .daily-reward-button:hover,
.site-shell-header .daily-reward-button:focus-visible {
    border-color: var(--color-danger, var(--color-primary, #16a34a));
    background: var(--color-danger-softer, var(--color-surface-soft, #f5f5f4));
    transform: translateY(-1px);
}

.site-shell-header .daily-reward-button:active,
.site-shell-header .login-btn:active,
.site-shell-header .user-menu-button:active {
    transform: translateY(1px);
}

.site-shell-header .daily-reward-icon,
.site-shell-header .notification-dot {
    flex: 0 0 auto;
}

.site-shell-header .daily-reward-icon {
    width: 16px;
    height: 16px;
}

.site-shell-header .notification-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-notification, #ef4444);
}

.site-shell-header .login-btn {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border: 0;
    border-radius: 10px;
    background: var(--color-primary, #16a34a);
    color: var(--color-on-primary, #fff);
    font-size: 13px;
    font-weight: 800;
}

.site-shell-header .login-btn:hover,
.site-shell-header .login-btn:focus-visible {
    background: var(--color-primary-strong, var(--color-primary, #16a34a));
    box-shadow: 0 8px 20px var(--color-primary-glow, rgba(22, 163, 74, .22));
    transform: translateY(-1px);
}

.site-shell-header .user-profile {
    position: relative;
}

.site-shell-header .user-menu-button {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--color-border, #e5dfd3);
    border-radius: 999px;
    background: var(--color-surface-soft, var(--color-bg-secondary, #fff));
    color: var(--color-text, #1c1917);
    font-size: 13px;
    font-weight: 700;
}

.site-shell-header .user-menu-button:hover,
.site-shell-header .user-menu-button:focus-visible {
    border-color: var(--color-primary, #16a34a);
    background: var(--color-primary-soft, var(--color-surface-soft, #f5f5f4));
}

.site-shell-header .user-avatar,
.site-shell-header .dropdown-avatar {
    display: block;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--color-primary-soft, #dcfce7);
    object-fit: cover;
}

.site-shell-header .user-avatar {
    width: 32px;
    height: 32px;
}

.site-shell-header .dropdown-avatar {
    width: 44px;
    height: 44px;
    border: 2px solid var(--color-primary-soft, #dcfce7);
}

.site-shell-header .user-name {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-shell-header .dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1000;
    width: min(320px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid var(--color-border, #e5dfd3);
    border-radius: 12px;
    background: var(--color-surface, var(--color-bg-secondary, #fff));
    box-shadow: var(--shadow-lg, 0 18px 40px rgba(28, 25, 23, .16));
}

.site-shell-header .dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--color-border, #e5dfd3);
}

.site-shell-header .dropdown-user-info {
    min-width: 0;
}

.site-shell-header .dropdown-name,
.site-shell-header .dropdown-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-shell-header .dropdown-name {
    color: var(--color-text, #1c1917);
    font-weight: 800;
}

.site-shell-header .dropdown-email {
    margin-top: 2px;
    color: var(--color-text-muted, #78716c);
    font-size: 12px;
}

.site-shell-header .profile-resources {
    display: grid;
    gap: 8px;
    padding: 12px 20px;
    background: var(--color-warning-soft, rgba(245, 158, 11, .12));
    border-bottom: 1px solid var(--color-border, #e5dfd3);
}

.site-shell-header .profile-resource {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 24px;
    color: var(--color-text-secondary, #57534e);
    font-size: 13px;
}

.site-shell-header .profile-resource-icon {
    width: 18px;
    height: 18px;
}

.site-shell-header .profile-resource-label {
    min-width: 0;
}

.site-shell-header .profile-resource-value {
    color: var(--color-text, #1c1917);
    font-weight: 800;
    white-space: nowrap;
}

.site-shell-header .profile-resource-cap {
    margin-left: 3px;
    color: var(--color-text-muted, #78716c);
    font-size: 11px;
    font-weight: 600;
}

.site-shell-header .profile-subscription {
    padding: 8px 20px 0;
    color: var(--color-primary-strong, var(--color-primary, #16a34a));
    font-size: 12px;
    font-weight: 800;
}

.site-shell-header .dropdown-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--color-border, #e5dfd3);
}

.site-shell-header .dropdown-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border: 0;
    background: transparent;
    color: var(--color-text-secondary, #57534e);
    font: inherit;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.site-shell-header .dropdown-item:hover,
.site-shell-header .dropdown-item:focus-visible {
    background: var(--color-surface-soft, #f5f5f4);
    color: var(--color-text, #1c1917);
    outline: none;
}

.site-shell-header .dropdown-item-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.site-shell-nav {
    position: relative;
    z-index: 90;
    border-bottom: 1px solid var(--color-border, #e5dfd3);
    background: var(--color-surface-subtle, var(--color-surface, #fff));
}

.site-shell-nav .subnav-content {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-shell-nav .nav-items {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.site-shell-nav .nav-items::-webkit-scrollbar {
    display: none;
}

.site-shell-nav .nav-link,
.site-shell-nav .theme-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--color-text-secondary, #57534e);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.site-shell-nav .nav-link {
    cursor: pointer;
}

.site-shell-nav .nav-icon,
.site-shell-nav .theme-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.site-shell-nav .nav-link:hover,
.site-shell-nav .nav-link:focus-visible {
    border-color: var(--color-border, #e5dfd3);
    background: var(--color-surface, #fff);
    color: var(--color-text, #1c1917);
}

.site-shell-nav .nav-link.active {
    border-color: var(--color-primary-strong, var(--color-primary, #16a34a));
    background: var(--color-primary, #16a34a);
    color: var(--color-on-primary, #fff);
    font-weight: 700;
}

.site-shell-nav .theme-toggle {
    flex: 0 0 auto;
    border-color: var(--color-border-strong, var(--color-border, #e5dfd3));
    background: var(--color-surface, #fff);
    color: var(--color-text, #1c1917);
    cursor: pointer;
}

.site-shell-nav .theme-toggle:hover,
.site-shell-nav .theme-toggle:focus-visible {
    border-color: var(--color-primary, #16a34a);
    background: var(--color-primary-soft, var(--color-surface-soft, #f5f5f4));
    color: var(--color-primary-strong, var(--color-primary, #16a34a));
}

.site-shell-nav .theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-warning-text, var(--color-primary, #16a34a));
    line-height: 1;
}

.site-shell-nav .theme-toggle-icon .theme-icon-dark {
    display: none;
}

html[data-theme="dark"] .site-shell-nav .theme-toggle-icon .theme-icon-light {
    display: none;
}

html[data-theme="dark"] .site-shell-nav .theme-toggle-icon .theme-icon-dark {
    display: inline;
}

.site-shell-footer {
    width: 100%;
    margin-top: auto;
    border-top: 1px solid var(--color-border, #e5dfd3);
    background: var(--color-surface-subtle, var(--color-surface, #fff));
}

.site-shell-footer .footer-content {
    min-height: 132px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px 0;
    text-align: center;
}

.site-shell-footer .footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 24px;
}

.site-shell-footer .footer-links a {
    color: var(--color-text-secondary, #57534e);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.site-shell-footer .footer-links a:hover,
.site-shell-footer .footer-links a:focus-visible {
    color: var(--color-primary-strong, var(--color-primary, #16a34a));
}

.site-shell-footer .footer-copyright {
    margin: 0;
    color: var(--color-text-muted, #78716c);
    font-size: 11px;
}

.site-shell-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 19, 26, .62);
}

.site-shell-modal.hidden {
    display: none;
}

.site-shell-daily-modal {
    position: relative;
    width: min(420px, 100%);
    padding: 32px 24px 24px;
    border: 1px solid var(--color-border, #e5dfd3);
    border-radius: 16px;
    background: var(--color-surface, var(--color-bg-secondary, #fff));
    color: var(--color-text, #1c1917);
    text-align: center;
    box-shadow: var(--shadow-lg, 0 18px 40px rgba(28, 25, 23, .16));
}

.site-shell-daily-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
    color: var(--color-text-muted, #78716c);
    font-size: 24px;
    cursor: pointer;
}

.site-shell-daily-modal h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.site-shell-daily-modal p {
    margin: 0 0 20px;
    color: var(--color-text-secondary, #57534e);
}

.site-shell-daily-claim {
    width: 100%;
    min-height: 42px;
    border-radius: 8px;
    background: var(--color-primary, #16a34a);
    color: var(--color-on-primary, #fff);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.site-shell-daily-claim:disabled {
    cursor: not-allowed;
    opacity: .6;
}

@media (max-width: 1100px) {
    .site-shell-header .header-content,
    .site-shell-nav .subnav-content,
    .site-shell-footer .footer-content {
        width: min(100% - 64px, 1440px);
    }
}

@media (max-width: 640px) {
    .site-shell-header .header-content {
        min-height: 64px;
        gap: 12px;
    }

    .site-shell-header .brand-mark {
        width: 34px;
        height: 34px;
    }

    .site-shell-header .brand-copy h1 {
        font-size: 18px;
    }

    .site-shell-header .header-actions,
    .site-shell-header #auth-container {
        gap: 8px;
    }

    .site-shell-header .daily-reward-button {
        padding-inline: 8px;
    }

    .site-shell-header .daily-reward-button > span:not(.notification-dot),
    .site-shell-header .user-name {
        display: none;
    }

    .site-shell-header .user-menu-button {
        padding-right: 4px;
    }

    .site-shell-nav .subnav-content {
        width: 100%;
        gap: 8px;
        padding: 0 12px;
    }

    .site-shell-nav .nav-items {
        flex: 1 1 auto;
    }

    .site-shell-nav .nav-link,
    .site-shell-nav .theme-toggle {
        padding-inline: 9px;
        font-size: 12px;
    }

    .site-shell-footer .footer-content {
        width: min(100% - 32px, 1440px);
        min-height: 112px;
        padding: 20px 0;
    }

    .site-shell-footer .footer-links {
        gap: 12px 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-shell-header .daily-reward-button,
    .site-shell-header .login-btn,
    .site-shell-header .user-menu-button {
        transition: none;
    }
}
