@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --bg: #0f0f0f;
    --fg: #fff;
    --border: rgba(255, 255, 255, 0.15);
    --muted: rgba(255, 255, 255, 0.4);
    --accent: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
    --bg: #f5f5f5;
    --fg: #000;
    --border: rgba(0, 0, 0, 0.15);
    --muted: rgba(0, 0, 0, 0.4);
    --accent: rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
    background: var(--bg);
    overflow-y: scroll;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--fg);
    background: var(--bg);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    scrollbar-gutter: stable;
}

/* ========== HEADER ========== */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg);
    height: 48px;
}

.header-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 12px;
    color: var(--fg);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo:hover {
    opacity: 0.6;
}

.logo .author {
    opacity: 0.5;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 0;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 12px;
    color: var(--fg);
    opacity: 0.4;
    cursor: pointer;
    transition: opacity 0.2s ease;
    text-transform: uppercase;
}

.mode-btn:hover {
    opacity: 0.7;
}

.mode-btn.active {
    opacity: 1;
}

.theme-btn {
    background: #222;
    border: none;
    padding: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 16px;
    color: var(--fg);
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-left: 16px;
    border-radius: 8px;
}

[data-theme="light"] .theme-btn {
    background: #ddd;
    color: var(--fg);
}

.theme-btn:hover {
    opacity: 0.7;
}

.theme-icon {
    width: 16px;
    height: 16px;
    display: block;
    color: currentColor;
}

.theme-icon-light {
    display: none !important;
}

.theme-icon-dark {
    display: block;
}

[data-theme="light"] .theme-icon-dark {
    display: none !important;
}

[data-theme="light"] .theme-icon-light {
    display: block !important;
}

.reset-btn {
    background: transparent;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 12px;
    color: var(--fg);
    opacity: 0.4;
    cursor: pointer;
    transition: opacity 0.2s ease;
    text-transform: uppercase;
    margin-left: auto;
}

.reset-btn:hover {
    opacity: 1;
}

/* ========== SHARED LAYOUT ========== */
.mode-content {
    display: none;
    padding-top: 48px;
    padding-bottom: 120px;
}

.mode-content.active {
    display: block;
}

/* Container */
.container,
.learn-container,
.block-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Sections */
.section,
.learn-section,
.block {
    padding: 80px 0;
}

/* Hero Section */
.hero-section,
#block-intro {
    min-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
}

/* ========== TYPOGRAPHY ========== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    margin-bottom: 24px;
}

.article-title {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 24px;
    opacity: 0.8;
}

p {
    font-size: 12px;
    margin-bottom: 16px;
    line-height: 1.8;
    opacity: 0.85;
}

p:last-child {
    margin-bottom: 0;
}

em {
    font-style: italic;
}

strong {
    font-weight: 500;
}

/* Labels */
.label,
.concept-num,
.part-label,
.part-time,
.output-label,
.synthesis-label,
.game-label,
.status-text {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-bottom: 8px;
}

/* Lead / Subtitle */
.lead,
.hero-sub,
.part-context {
    font-size: 12px;
    line-height: 1.8;
    opacity: 0.6;
    margin-bottom: 32px;
}

.hero-meta {
    font-size: 12px;
    opacity: 0.4;
    margin-bottom: 48px;
}

/* ========== COMPONENTS ========== */

/* Buttons */
.btn,
.start-execute-btn,
.continue-btn {
    background: var(--fg);
    color: var(--bg);
    border: none;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: inline-block;
    margin-top: 24px;
    text-transform: uppercase;
    border-radius: 8px;
}

.btn:hover,
.start-execute-btn:hover,
.continue-btn:hover:not(:disabled) {
    opacity: 0.7;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.scroll-btn {
    background: #222;
    color: var(--fg);
    border: none;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    text-transform: uppercase;
    display: inline-block;
    border-radius: 8px;
}

[data-theme="light"] .scroll-btn {
    background: #ddd;
    color: var(--fg);
}

.hero-buttons .start-execute-btn,
.hero-buttons .scroll-btn {
    margin-top: 0;
    padding: 14px 28px;
    line-height: 1.4;
}

.scroll-btn:hover {
    opacity: 0.6;
}

.continue-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}


.export-btn {
    background: #222;
    color: var(--fg);
    border: none;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-top: 48px;
    text-transform: uppercase;
    border-radius: 8px;
}

.export-btn:hover {
    opacity: 0.6;
}

[data-theme="light"] .export-btn {
    background: #ddd;
    color: var(--fg);
}

/* Blockquotes */
blockquote {
    margin: 32px 0;
    padding-left: 24px;
    border-left: 1px solid var(--border);
}

blockquote p {
    font-size: 12px;
    line-height: 1.8;
    opacity: 0.9;
    margin-bottom: 8px;
}

blockquote cite {
    font-size: 12px;
    opacity: 0.4;
    font-style: normal;
}

/* Callouts / Warning */
.callout,
.warning {
    margin: 32px 0;
    padding: 24px;
    background: #1a1a1a;
    border: none;
    border-radius: 8px;
}

[data-theme="light"] .callout {
    background: #e8e8e8;
}

[data-theme="light"] .warning {
    background: #e8e8e8;
}

.callout p,
.warning p {
    font-size: 12px;
    margin-bottom: 8px;
    opacity: 0.85;
}

.callout p:last-child,
.warning p:last-child {
    margin-bottom: 0;
}

/* Lists */
.numbered-list,
.formula-list {
    margin: 24px 0;
    padding-left: 0;
    list-style: none;
    counter-reset: item;
}

.numbered-list li,
.formula-list li {
    position: relative;
    padding-left: 32px;
    margin-bottom: 12px;
    font-size: 12px;
    line-height: 1.8;
    opacity: 0.85;
}

.numbered-list li::before {
    content: counter(item);
    counter-increment: item;
    position: absolute;
    left: 0;
    font-size: 12px;
    opacity: 0.4;
}

.formula-list li::before {
    content: '—';
    position: absolute;
    left: 0;
    opacity: 0.4;
}

/* Stages / Phases / Items */
.stages-list,
.phases,
.game-framework,
.protocol-parts {
    margin: 32px 0;
}

.stage,
.phase,
.game-item,
.protocol-part,
.output-row,
.interrupt-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.stage:last-child,
.phase:last-child,
.game-item:last-child,
.protocol-part:last-child,
.output-row:last-child,
.interrupt-item:last-child {
    border-bottom: none;
}

.stage,
.phase {
    display: flex;
    gap: 16px;
}

.stage-num {
    font-size: 12px;
    opacity: 0.4;
    width: 24px;
    flex-shrink: 0;
}

.phase-num {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.4;
    width: 24px;
    flex-shrink: 0;
}

.stage-content strong,
.phase-content strong,
.protocol-part strong {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.stage-content p,
.phase-content p,
.protocol-part p,
.game-item p {
    font-size: 12px;
    margin-bottom: 0;
    opacity: 0.6;
}

.game-meta {
    display: block;
    font-size: 12px;
    opacity: 0.4;
    margin-bottom: 8px;
}

/* Protocol Overview */
.protocol-overview {
    background: transparent;
}

.protocol-intro {
    font-size: 12px;
    margin-bottom: 48px;
    opacity: 0.6;
}

/* Commitment */
.commitment {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 32px;
}

.commitment input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 3px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--fg);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    appearance: none;
    -webkit-appearance: none;
    border-radius: 8px;
}

.commitment input[type="checkbox"]:checked {
    background: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='3' fill='%23000'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

[data-theme="light"] .commitment input[type="checkbox"] {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .commitment input[type="checkbox"]:checked {
    background: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='3' fill='%23000'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.commitment span {
    font-size: 12px;
    line-height: 1.6;
    opacity: 0.8;
}

/* Part Headers */
.part-header {
    margin-bottom: 48px;
}

/* Question Blocks */
.question-block {
    margin-bottom: 48px;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.hidden {
    display: none !important;
}

.question {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 8px;
    position: relative;
}

.context {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    margin-bottom: 16px;
}

/* Inputs */
.response {
    width: 100%;
    padding: 16px;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.6;
    background: #0a0a0a;
    color: var(--fg);
    border: none;
    resize: vertical;
    transition: background 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 8px;
}

[data-theme="light"] .response {
    background: #e8e8e8;
}

.response:focus {
    outline: none;
    background: #0a0a0a;
}

[data-theme="light"] .response:focus {
    background: #e8e8e8;
}

.response::placeholder {
    color: var(--muted);
}

.response::selection {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .response::selection {
    background: rgba(0, 0, 0, 0.2);
}

.response-line {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.6;
    background: #0a0a0a;
    color: var(--fg);
    border: none;
    transition: background 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 8px;
}

[data-theme="light"] .response-line {
    background: #e8e8e8;
}

.response-line:focus {
    outline: none;
    background: #0a0a0a;
}

[data-theme="light"] .response-line:focus {
    background: #e8e8e8;
}

.response-line::placeholder {
    color: var(--muted);
}

.response-line::selection {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .response-line::selection {
    background: rgba(0, 0, 0, 0.2);
}

.custom-time-picker {
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-hour,
.time-minute {
    padding: 8px;
    font-family: inherit;
    font-size: 12px;
    background: #222;
    color: var(--fg);
    border: none;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    min-width: 50px;
}

[data-theme="light"] .time-hour,
[data-theme="light"] .time-minute {
    background: #ddd;
    color: var(--fg);
}

.time-hour:focus,
.time-minute:focus {
    outline: none;
    background: #2a2a2a;
}

[data-theme="light"] .time-hour:focus,
[data-theme="light"] .time-minute:focus {
    background: #d0d0d0;
}

.time-separator {
    color: var(--fg);
    opacity: 0.6;
    font-size: 12px;
}

/* Style select dropdown options */
.time-hour option,
.time-minute option {
    background: #222;
    color: var(--fg);
}

[data-theme="light"] .time-hour option,
[data-theme="light"] .time-minute option {
    background: #ddd;
    color: var(--fg);
}

/* Interrupts Grid */
.interrupts-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 24px;
}

.interrupt-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 24px;
    align-items: center;
}

.interrupt-q {
    font-size: 12px;
    line-height: 1.5;
    opacity: 0.6;
}

/* Synthesis Bar */
/* Synthesis Toggle Button (sticky bottom) */
.synthesis-toggle-btn {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 98;
    background: #222;
    border: none;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 12px;
    color: var(--fg);
    cursor: pointer;
    text-transform: uppercase;
    transition: opacity 0.2s ease;
    display: none;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .synthesis-toggle-btn {
    background: #fff;
    color: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.synthesis-toggle-btn.visible {
    display: block;
}

.synthesis-toggle-btn:hover {
    opacity: 0.7;
}

/* Synthesis Modal Overlay */
.synthesis-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.synthesis-modal.active {
    display: flex;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 15, 0.5);
    backdrop-filter: blur(12px);
}

[data-theme="light"] .modal-backdrop {
    background: rgba(245, 245, 245, 0.6);
    backdrop-filter: blur(12px);
}

.modal-content {
    position: relative;
    max-width: 640px;
    width: 100%;
    z-index: 201;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    padding: 0 24px;
}

.synthesis-modal.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: #000;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    text-transform: none;
    font-weight: 300;
    z-index: 10;
}

.modal-close:hover {
    opacity: 1;
}

.synthesis-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    color: #000;
}

[data-theme="light"] .synthesis-card {
    background: #fff;
    color: #000;
}

.synthesis-tabs {
    display: flex;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.synthesis-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 20px 24px;
    font-family: inherit;
    font-size: 12px;
    color: #000;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    border-bottom: 2px solid transparent;
}

.synthesis-tab:hover {
    opacity: 0.7;
}

.synthesis-tab.active {
    opacity: 1;
    border-bottom-color: #000;
}

.tab-content {
    display: none;
    padding: 24px;
    flex: 1;
    min-height: 200px;
}

.tab-content.active {
    display: block;
}

.synthesis-text {
    font-size: 12px;
    line-height: 1.8;
    color: #000;
    opacity: 0.9;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Final Output */
.final-output {
    margin-bottom: 48px;
}

.output-text {
    font-size: 12px;
    line-height: 1.6;
}

.final-note {
    font-size: 12px;
    opacity: 0.5;
    margin-top: 48px;
    padding-top: 48px;
    border-top: 1px solid var(--border);
}

/* ========== FOOTER ========== */
/* Sticky Footer */
.sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg);
    height: 48px;
}

.footer-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sticky-footer a {
    color: var(--fg);
    text-decoration: none;
    font-size: 12px;
    transition: opacity 0.2s ease;
}

.sticky-footer a:hover {
    opacity: 0.6;
}

.sticky-footer span {
    font-size: 12px;
    color: var(--muted);
}

.footer-divider {
    opacity: 0.3;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.block:not(.hidden),
.learn-section {
    animation: fadeIn 0.6s ease-out;
}

.question-block:not(.hidden) {
    animation: fadeIn 0.4s ease-out;
}

/* Info Icon */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    cursor: help;
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    position: relative;
}

.info-icon:hover {
    opacity: 1;
}

.info-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.info-icon {
    color: var(--muted);
}

.info-icon:hover {
    color: var(--fg);
}

.info-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.info-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--fg);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 320px;
    min-width: 240px;
    z-index: 1000;
    text-transform: none;
    letter-spacing: 0;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .info-tooltip {
    background: #fff;
    border-color: var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.info-icon:hover .info-tooltip {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ========== MOBILE ========== */
@media (max-width: 640px) {
    .mode-btn {
        padding: 8px 12px;
    }

    .section,
    .learn-section,
    .block {
        padding: 60px 0;
    }

    .interrupt-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }


    .stage,
    .phase {
        flex-direction: column;
        gap: 8px;
    }

    .stage-num,
    .phase-num {
        width: auto;
    }

    .info-tooltip {
        max-width: 280px;
        min-width: 200px;
        font-size: 10px;
        padding: 10px 12px;
    }
}

/* ========== PRINT ========== */
@media print {
    header, footer, .continue-btn, .export-btn, .synthesis-modal, .synthesis-toggle-btn, .mode-toggle {
        display: none !important;
    }

    .mode-content {
        display: block !important;
    }

    .block,
    .learn-section {
        display: block !important;
        min-height: auto;
        padding: 24px 0;
        page-break-inside: avoid;
    }

    .block.hidden,
    .question-block.hidden {
        display: block !important;
    }
}
