/* ============================================
   SelfSmith — Premium Dark PWA
   Mobile-first | Warm gold on near-black
   ============================================ */

/* ---------- Reset & Foundation ---------- */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a14;
    --surface: #141428;
    --gold: #c9a04e;
    --gold-light: #d4b06a;
    --purple: #7c5cbf;
    --text: #e8e0d4;
    --text-secondary: #8a8090;
    --success: #4ade80;
    --warning: #f97316;
    --border: #1e1e3a;

    --gold-gradient: linear-gradient(135deg, #c9a04e, #d4b06a);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    --screen-transition: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Screen System ---------- */

.screen {
    position: fixed;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition:
        opacity var(--screen-transition),
        transform var(--screen-transition),
        visibility 0s linear 0.5s;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition:
        opacity var(--screen-transition),
        transform var(--screen-transition),
        visibility 0s linear 0s;
    z-index: 10;
}

.screen-inner {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: 24px 24px env(safe-area-inset-bottom, 24px);
    max-width: 480px;
    margin: 0 auto;
}


/* ---------- Buttons ---------- */

.btn {
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-gold {
    background: var(--gold-gradient);
    color: var(--bg);
    padding: 16px 40px;
    box-shadow: 0 4px 24px rgba(201, 160, 78, 0.2);
}

.btn-gold:hover {
    box-shadow: 0 6px 32px rgba(201, 160, 78, 0.35);
}

.btn-gold:active {
    box-shadow: 0 2px 12px rgba(201, 160, 78, 0.15);
}

.btn-large {
    font-size: 1.125rem;
    padding: 18px 48px;
}

.btn-full {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 16px 24px;
}

.btn-ghost:hover {
    color: var(--text);
}

.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--text);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8125rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}

.btn-link:hover {
    color: var(--text);
}

.hidden {
    display: none !important;
}


/* ============================================
   SCREEN 1: Landing
   ============================================ */

.landing-inner {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.landing-mark {
    margin-bottom: 24px;
    opacity: 0.9;
}

.landing-headline {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 4px;
}

.landing-subline {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 300px;
    margin-bottom: 32px;
}

.landing-tagline {
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
}

.landing-legal {
    margin-top: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.7rem;
}

.landing-legal a {
    color: var(--text-secondary);
    text-decoration: none;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.landing-legal a:hover {
    opacity: 0.8;
    color: var(--accent-gold);
}

.legal-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.3;
}


/* ============================================
   SCREEN 2: Questionnaire
   ============================================ */

.questions-inner {
    justify-content: space-between;
    padding-top: 48px;
}

/* Progress dots */
.progress-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-bottom: 32px;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.4s ease;
}

.progress-dot.active {
    background: var(--gold);
    box-shadow: 0 0 8px rgba(201, 160, 78, 0.4);
}

.progress-dot.completed {
    background: var(--gold);
    opacity: 0.5;
}

/* Question container */
.question-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    padding-top: 16px;
    position: relative;
    overflow: hidden;
}

.question-slide {
    width: 100%;
    flex-shrink: 0;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.question-slide.exit-left {
    opacity: 0;
    transform: translateX(-40px);
    position: absolute;
}

.question-slide.enter-right {
    opacity: 0;
    transform: translateX(40px);
    position: absolute;
}

.question-slide.exit-right {
    opacity: 0;
    transform: translateX(40px);
    position: absolute;
}

.question-slide.enter-left {
    opacity: 0;
    transform: translateX(-40px);
    position: absolute;
}

.question-text {
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 28px;
    letter-spacing: -0.01em;
}

/* Inputs */
.q-input,
.q-textarea {
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    padding: 16px 18px;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    -webkit-appearance: none;
}

.q-input::placeholder,
.q-textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.q-input:focus,
.q-textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 160, 78, 0.12);
}

.q-textarea {
    min-height: 140px;
    resize: none;
    line-height: 1.5;
}

/* Identity statements */
.identity-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.identity-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.identity-prefix {
    font-size: 0.8125rem;
    color: var(--gold);
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Multiple choice grid */
.mc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.mc-option {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.mc-option:active {
    transform: scale(0.97);
}

.mc-option.selected {
    border-color: var(--gold);
    background: rgba(201, 160, 78, 0.08);
    box-shadow: 0 0 0 1px var(--gold);
}

/* Navigation */
.question-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 24px;
    padding-bottom: 12px;
}


/* ============================================
   SCREEN 3: Paywall
   ============================================ */

.paywall-inner {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.paywall-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.paywall-headline {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-bottom: 36px;
    max-width: 280px;
}

.paywall-features {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 40px;
    align-self: flex-start;
    padding-left: 8px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
}

.feature-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.feature-text {
    font-size: 0.9375rem;
    color: var(--text);
}

.paywall-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 32px;
}

.price-amount {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

.price-period {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.paywall-cancel {
    margin-top: 14px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.invite-section {
    margin-top: 24px;
    text-align: center;
}

.invite-form {
    margin-top: 12px;
}

.invite-form .input-row {
    display: flex;
    align-items: center;
}

.invite-error {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #f97316;
}

.paywall-stripe {
    margin-top: 48px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
}


/* ============================================
   SCREEN 4: Generating
   ============================================ */

.generating-inner {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.generating-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.generating-headline {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 40px;
    letter-spacing: -0.01em;
}

/* Animated orb */
.generating-orb {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 48px;
}

.orb-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid var(--gold);
}

.orb-ring-1 {
    opacity: 0.3;
    animation: orb-pulse 3s ease-in-out infinite;
}

.orb-ring-2 {
    inset: 12px;
    opacity: 0.5;
    animation: orb-pulse 3s ease-in-out infinite 0.5s;
}

.orb-ring-3 {
    inset: 24px;
    opacity: 0.7;
    animation: orb-pulse 3s ease-in-out infinite 1s;
}

.orb-core {
    position: absolute;
    inset: 36px;
    border-radius: 50%;
    background: var(--gold-gradient);
    opacity: 0.8;
    animation: orb-glow 2s ease-in-out infinite;
}

@keyframes orb-pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.08); opacity: 0.6; }
}

@keyframes orb-glow {
    0%, 100% { opacity: 0.6; box-shadow: 0 0 20px rgba(201, 160, 78, 0.2); }
    50% { opacity: 0.9; box-shadow: 0 0 40px rgba(201, 160, 78, 0.4); }
}

/* Phase list */
.generating-phases {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: flex-start;
    padding-left: 12px;
    margin-bottom: 40px;
    width: 100%;
}

.phase-item {
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0.3;
    transition: all 0.5s ease;
}

.phase-item.active {
    opacity: 1;
}

.phase-item.done {
    opacity: 0.6;
}

.phase-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    flex-shrink: 0;
    position: relative;
    transition: all 0.4s ease;
}

.phase-item.active .phase-indicator {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(201, 160, 78, 0.3);
    animation: phase-spin 1.5s linear infinite;
}

.phase-item.active .phase-indicator::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--gold);
    animation: phase-spin 1s linear infinite;
}

.phase-item.done .phase-indicator {
    border-color: var(--success);
    background: var(--success);
}

.phase-item.done .phase-indicator::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 3px;
    width: 10px;
    height: 5px;
    border-left: 2px solid var(--bg);
    border-bottom: 2px solid var(--bg);
    transform: rotate(-45deg);
    animation: none;
}

@keyframes phase-spin {
    to { transform: rotate(360deg); }
}

.phase-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    transition: color 0.4s ease;
}

.phase-item.active .phase-label {
    color: var(--text);
    font-weight: 500;
}

.phase-item.done .phase-label {
    color: var(--text-secondary);
}

.generating-note {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    opacity: 0.6;
}


/* ============================================
   SCREEN 5: Player
   ============================================ */

.player-inner {
    justify-content: space-between;
    padding-top: 48px;
    padding-bottom: 32px;
}

.player-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.streak-display {
    display: flex;
    flex-direction: column;
}

.streak-number {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--text);
}

.streak-status {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Streak status colors */
.streak-status.status-mediocre { color: var(--warning); }
.streak-status.status-starting,
.streak-status.status-building { color: var(--text); }
.streak-status.status-committed,
.streak-status.status-dedicated { color: var(--gold); }
.streak-status.status-hero,
.streak-status.status-champion { color: var(--success); }
.streak-status.status-legend { color: var(--purple); }

/* Player center */
.player-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.play-ring-container {
    position: relative;
    width: 200px;
    height: 200px;
}

.progress-ring {
    transform: rotate(0deg);
}

.progress-ring-bg {
    stroke: var(--border);
}

.progress-ring-fill {
    stroke-dasharray: 565.48;  /* 2 * PI * 90 */
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.3s ease;
}

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: var(--gold-gradient);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 32px rgba(201, 160, 78, 0.3);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.play-button:hover {
    box-shadow: 0 8px 40px rgba(201, 160, 78, 0.45);
}

.play-button:active {
    transform: translate(-50%, -50%) scale(0.95);
    box-shadow: 0 4px 20px rgba(201, 160, 78, 0.2);
}

.play-icon {
    margin-left: 4px; /* optical center for play triangle */
}

.player-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}

.time-sep {
    margin: 0 4px;
    opacity: 0.4;
}

/* Player bottom */
.player-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.btn-complete {
    margin-bottom: 8px;
    animation: complete-appear 0.5s ease;
}

@keyframes complete-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.week-dots {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.week-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    transition: all 0.3s ease;
}

.week-dot.filled {
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(201, 160, 78, 0.3);
}

.week-labels {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: -8px;
}

.week-labels span {
    width: 12px;
    text-align: center;
    font-size: 0.625rem;
    color: var(--text-secondary);
    opacity: 0.5;
    letter-spacing: 0;
}

.player-footer {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

#regen-count {
    opacity: 0.6;
    font-size: 0.75rem;
}


/* ============================================
   Responsive — larger screens
   ============================================ */

@media (min-width: 481px) {
    .screen-inner {
        padding: 40px 32px;
    }

    .landing-headline {
        font-size: 2.5rem;
    }

    .question-text {
        font-size: 1.5rem;
    }
}

/* Extra tall phones — add breathing room */
@media (min-height: 800px) {
    .questions-inner {
        padding-top: 72px;
    }

    .player-inner {
        padding-top: 64px;
    }
}

/* Landscape safety */
@media (max-height: 500px) {
    .generating-orb {
        width: 64px;
        height: 64px;
        margin-bottom: 24px;
    }

    .play-ring-container {
        width: 140px;
        height: 140px;
    }

    .play-ring-container .progress-ring {
        width: 140px;
        height: 140px;
    }

    .play-button {
        width: 60px;
        height: 60px;
    }

    .streak-number {
        font-size: 2.5rem;
    }
}


/* ============================================
   Utility & Accessibility
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard nav */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Scrollbar styling for textareas */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Selection */
::selection {
    background: rgba(201, 160, 78, 0.3);
    color: var(--text);
}
