/* =============================================
   FONT FACES
   ============================================= */

@font-face {
    font-family: 'DIN Alternate';
    src: url('./fonts/DIN Alternate Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'DM Mono';
    src: url('./fonts/DMMono-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'DM Sans';
    src: url('./fonts/DMSans_18pt-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Minion Pro';
    src: url('./fonts/MinionPro-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* =============================================
   BASE
   ============================================= */

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: 'DM Sans', sans-serif;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

@supports (overflow: clip) {
    html,
    body {
        overflow-x: clip;
    }
}

body.mobile-menu-open {
    overflow: hidden;
}

a {
    transition: color 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}

/* =============================================
   NAVBAR
   ============================================= */

#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    height: 64px;
    background: transparent;
    transition: background 0.4s ease, backdrop-filter 0.4s ease, box-shadow 0.4s ease;
}

#navbar.scrolled {
    background: rgba(253, 253, 253, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

#nav-logo {
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

#nav-logo.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-left: auto;
    list-style: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
}

body:not(.intro-complete) #nav-links,
body:not(.intro-complete) .nav-hamburger {
    opacity: 0;
    pointer-events: none;
}

.nav-hamburger {
    display: none;
    margin-left: auto;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    padding: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    z-index: 110;
}

.nav-hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: #1a1a1a;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

.nav-hamburger.is-open .nav-hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-hamburger.is-open .nav-hamburger-line:nth-child(2) {
    opacity: 0;
}

.nav-hamburger.is-open .nav-hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-menu.visible {
    opacity: 1;
    pointer-events: auto;
}

.mobile-nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.mobile-menu-link {
    font-family: 'DM Mono', monospace;
    font-size: 1.4rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    text-decoration: none;
    color: #1a1a1a;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    color: #1a1a1a;
    text-decoration: none;
}

.nav-text-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.nav-dot-label {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
}

.nav-link:hover {
    opacity: 0.5;
}

/* =============================================
   HERO AND SECTIONS
   ============================================= */

.subtitle-anim {
    font-family: 'DIN Alternate', 'DM Mono', monospace;
    font-weight: bold;
}

body:not(.intro-complete) .subtitle-anim {
    opacity: 0;
}

.hero-rich-text {
    max-width: min(90vw, 780px);
}

/* Scroll hint animation */
.hero-scroll-hint {
    transition: opacity 0.6s ease;
}

@keyframes scroll-hint-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

.animate-scroll-hint {
    animation: scroll-hint-bob 2s ease-in-out infinite;
}

.animate-scroll-hint .scroll-dot {
    animation: scroll-dot-move 2s ease-in-out infinite;
}

@keyframes scroll-dot-move {
    0% { cy: 8; opacity: 1; }
    50% { cy: 18; opacity: 0.4; }
    100% { cy: 8; opacity: 1; }
}

.cms-section-body {
    width: 100%;
}

.cms-dot-heading {
    width: 100%;
    display: flex;
    justify-content: center;
}

.dot-fallback-heading {
    font-family: 'DIN Alternate', 'DM Mono', monospace;
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #111;
}

/* =============================================
   RICH CONTENT (improved readability)
   ============================================= */

.rich-content {
    font-family: 'DM Sans', sans-serif;
    color: #3a3a3a;
}

.rich-content > *:first-child {
    margin-top: 0;
}

.rich-content > *:last-child {
    margin-bottom: 0;
}

.rich-content p,
.rich-content ul,
.rich-content ol,
.rich-content blockquote,
.rich-content h1,
.rich-content h2,
.rich-content h3,
.rich-content h4 {
    margin: 0 0 1rem;
}

.rich-content h1,
.rich-content h2,
.rich-content h3,
.rich-content h4 {
    font-family: 'DIN Alternate', 'DM Sans', sans-serif;
    color: #111;
    line-height: 1.1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.rich-content h1 {
    font-size: clamp(2.4rem, 5vw, 3.8rem);
}

.rich-content h2 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.rich-content h3 {
    font-size: clamp(1.4rem, 2vw, 2rem);
}

.rich-content p,
.rich-content li {
    font-size: 1.125rem;
    line-height: 1.85;
    max-width: 38em;
    font-family: 'Minion Pro', serif;
}

.rich-content ul,
.rich-content ol {
    padding-left: 1.3em;
    text-align: left;
}

.rich-content blockquote {
    border-left: 3px solid rgba(17, 24, 39, 0.15);
    padding-left: 1rem;
    color: #4b5563;
    font-style: italic;
    text-align: left;
}

.rich-content a {
    color: #0f172a;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.16em;
}

.rich-content strong {
    font-weight: 700;
    color: #111827;
}

.rich-content em {
    font-style: italic;
}

/* =============================================
   CMS / ADMIN BRAND THEME
   ============================================= */

:root {
    --cms-bg: #faf9f7;
    --cms-surface: #ffffff;
    --cms-accent: #1a1a1a;
    --cms-accent-hover: #333333;
    --cms-border: rgba(0, 0, 0, 0.08);
    --cms-border-strong: rgba(0, 0, 0, 0.14);
    --cms-text: #1a1a1a;
    --cms-text-muted: #6b7280;
    --cms-success: #059669;
    --cms-error: #dc2626;
    --cms-warn: #d97706;
    --cms-brand-pink: #FF85AA;
    --cms-brand-blue: #325AF1;
    --cms-brand-orange: #FF7000;
}

body.admin-pending #auth-gate,
body.admin-pending #access-denied,
body.admin-pending #admin-app {
    opacity: 0;
    pointer-events: none;
}

.cms-shell-hidden {
    display: none !important;
}

/* CMS branded header stripe */
.cms-header-stripe {
    height: 3px;
    background: linear-gradient(90deg, var(--cms-brand-pink), var(--cms-brand-orange), var(--cms-brand-blue));
    border-radius: 3px 3px 0 0;
}

/* CMS inputs */
.cms-input,
.cms-textarea {
    width: 100%;
    border: 1px solid var(--cms-border-strong);
    border-radius: 0.75rem;
    background: white;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--cms-text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: 'DM Sans', sans-serif;
}

.cms-input:focus,
.cms-textarea:focus,
.rich-editor-wrap:focus-within {
    border-color: var(--cms-brand-blue);
    box-shadow: 0 0 0 3px rgba(50, 90, 241, 0.1);
}

/* Rich editor */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--cms-border);
    background: #fafafa;
}

.editor-toolbar button {
    border: 1px solid var(--cms-border-strong);
    background: white;
    color: var(--cms-text);
    border-radius: 0.5rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.72rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: 'DM Mono', monospace;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.editor-toolbar button:hover {
    background: #f0f0f0;
    border-color: var(--cms-border-strong);
}

.rich-editor-surface {
    min-height: 160px;
    padding: 1rem;
    outline: none;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--cms-text);
}

.rich-editor-surface:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
}

.rich-editor-wrap {
    border: 1px solid var(--cms-border-strong);
    border-radius: 1rem;
    overflow: hidden;
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Validation status */
.glyph-status {
    min-height: 1.3rem;
    font-size: 0.78rem;
    line-height: 1.4;
    font-family: 'DM Sans', sans-serif;
}

.glyph-status-ok {
    color: var(--cms-success);
}

.glyph-status-error {
    color: var(--cms-error);
}

/* Checkbox rows */
.cms-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: #374151;
}

.cms-checkbox-row input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--cms-brand-blue);
}

/* Section cards - collapsible */
.cms-section-card {
    border: 1px solid var(--cms-border);
    border-radius: 1rem;
    background: white;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cms-section-card:hover {
    border-color: var(--cms-border-strong);
}

.cms-section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    gap: 1rem;
    transition: background 0.15s;
}

.cms-section-card-header:hover {
    background: #fafafa;
}

.cms-section-card-header .section-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.cms-section-card-header .section-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--cms-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
}

.cms-section-card-header .section-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cms-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cms-section-card-header .collapse-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    transition: transform 0.25s ease;
    color: #9ca3af;
}

.cms-section-card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.cms-section-card-body {
    padding: 0 1.25rem 1.25rem;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
}

.cms-section-card.collapsed .cms-section-card-body {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* CMS buttons */
.cms-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 0.6rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    border: 1px solid transparent;
}

.cms-btn-primary {
    background: var(--cms-accent);
    color: white;
    border-color: var(--cms-accent);
}

.cms-btn-primary:hover {
    background: var(--cms-accent-hover);
}

.cms-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cms-btn-secondary {
    background: white;
    color: var(--cms-text);
    border-color: var(--cms-border-strong);
}

.cms-btn-secondary:hover {
    background: #f5f5f5;
}

.cms-btn-danger {
    background: white;
    color: var(--cms-error);
    border-color: rgba(220, 38, 38, 0.25);
}

.cms-btn-danger:hover {
    background: #fef2f2;
}

.cms-btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

/* CMS field labels */
.cms-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.4rem;
    font-family: 'DM Sans', sans-serif;
}

.cms-field-help {
    font-size: 0.78rem;
    color: var(--cms-text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* CMS card containers */
.cms-card {
    border: 1px solid var(--cms-border);
    border-radius: 1rem;
    background: var(--cms-surface);
    padding: 1.5rem;
    transition: border-color 0.2s;
}

/* Publish bar */
.cms-publish-bar {
    position: sticky;
    bottom: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--cms-border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.04);
}

.cms-publish-bar .publish-status {
    font-size: 0.85rem;
    color: var(--cms-text-muted);
    flex: 1;
    min-width: 0;
}

/* Preview panel */
.cms-preview-panel {
    border: 1px solid var(--cms-border);
    border-radius: 1rem;
    background: white;
    overflow: hidden;
}

.cms-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--cms-border);
    background: #fafafa;
}

.cms-preview-header span {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--cms-text-muted);
    font-family: 'DM Mono', monospace;
}

.cms-preview-frame {
    width: 100%;
    min-height: 500px;
    border: 0;
    display: block;
}

/* Inline validation hints */
.cms-inline-error {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--cms-error);
    margin-top: 0.35rem;
    line-height: 1.4;
}

.cms-inline-error svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.cms-inline-success {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--cms-success);
    margin-top: 0.35rem;
    line-height: 1.4;
}

/* Toast notification */
.cms-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    background: var(--cms-accent);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-family: 'DM Sans', sans-serif;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    max-width: 400px;
}

.cms-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.cms-toast.toast-error {
    background: var(--cms-error);
}

.cms-toast.toast-success {
    background: var(--cms-success);
}

/* =============================================
   BUILDER BRAND THEME
   ============================================= */

.builder-sidebar {
    font-family: 'DM Sans', sans-serif;
}

.builder-sidebar .builder-section-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--cms-text-muted);
    margin-bottom: 0.5rem;
    font-family: 'DM Mono', monospace;
}

.builder-sidebar .builder-help {
    font-size: 0.8rem;
    color: var(--cms-text-muted);
    line-height: 1.5;
}

.builder-letter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    border: 1px solid var(--cms-border-strong);
    background: white;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cms-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    font-family: 'DM Mono', monospace;
}

.builder-letter-btn:hover {
    background: #f5f5f5;
    border-color: var(--cms-accent);
}

.builder-letter-btn.active {
    background: var(--cms-accent);
    color: white;
    border-color: var(--cms-accent);
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 900px) {
    #navbar {
        padding: 0 1rem;
    }

    #nav-links {
        gap: 1rem;
    }

    .nav-text-label {
        font-size: 0.68rem;
    }
}

@media (max-width: 767px) {
    #navbar {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #nav-links {
        display: none;
    }

    .nav-hamburger {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    .rich-content p,
    .rich-content li {
        font-size: 1rem;
    }

    .editor-toolbar {
        gap: 0.3rem;
    }

    .editor-toolbar button {
        font-size: 0.65rem;
        padding: 0.3rem 0.5rem;
    }

    .cms-publish-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}
