/* Chaos Magician — Sigil Forge */

:root {
    --void: #0a0612;
    --abyss: #12081f;
    --violet-deep: #1a0a2e;
    --phosphor: #3dff8a;
    --phosphor-dim: #22883a;
    --gold: #c9a227;
    --gold-faint: rgba(201, 162, 39, 0.35);
    --ash: #888;
    --mist: rgba(180, 220, 200, 0.12);
    --border: rgba(61, 255, 138, 0.25);
    --border-gold: rgba(201, 162, 39, 0.3);
    --glow-green: 0 0 20px rgba(34, 136, 34, 0.45);
    --glow-gold: 0 0 16px rgba(201, 162, 39, 0.35);
    --font-display: 'Cinzel Decorative', 'Trajan Pro', serif;
    --font-body: 'EB Garamond', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
    scroll-behavior: smooth;
}

html, body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    background: var(--void);
    color: #b8d4be;
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Void canvas & atmosphere */
#void-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.veil {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 50% 40%, transparent 0%, var(--void) 75%),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
    opacity: 0.9;
}

.sacred-ring {
    position: fixed;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 1px solid var(--gold-faint);
    pointer-events: none;
    z-index: 1;
    opacity: 0.15;
}

.sacred-ring--outer {
    width: min(90vmin, 700px);
    height: min(90vmin, 700px);
    transform: translate(-50%, -50%);
    animation: ring-drift 120s linear infinite;
}

.sacred-ring--inner {
    width: min(55vmin, 420px);
    height: min(55vmin, 420px);
    transform: translate(-50%, -50%);
    animation: ring-drift 90s linear infinite reverse;
    border-style: dashed;
}

@keyframes ring-drift {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 7 Hz pulse — homage to original */
body.pulse-7hz .sigil-frame,
body.pulse-7hz .site-header,
body.pulse-7hz .panel {
    animation: shake-7hz 142.86ms linear infinite;
}

@keyframes shake-7hz {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(0.8px, -0.5px); }
    50%  { transform: translate(-0.6px, 0.7px); }
    75%  { transform: translate(0.5px, 0.4px); }
    100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .sacred-ring,
    body.pulse-7hz .sigil-frame,
    body.pulse-7hz .site-header,
    body.pulse-7hz .panel {
        animation: none !important;
    }
    .sigil-frame--companion { animation: none !important; }
    html { scroll-behavior: auto; }
}

/* Layout */
.site-header,
.forge,
.site-footer {
    position: relative;
    z-index: 2;
}

.site-header {
    text-align: center;
    padding: 2.5rem 1.25rem 1rem;
}

.sigil-mark {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    color: var(--gold);
    filter: drop-shadow(var(--glow-gold));
    animation: mark-pulse 4s ease-in-out infinite;
}

@keyframes mark-pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.site-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    color: var(--ash);
    margin: 0;
    letter-spacing: 0.12em;
    text-shadow: var(--glow-green);
}

.site-tagline {
    margin: 0.5rem 0 0;
    font-style: italic;
    color: rgba(184, 212, 190, 0.6);
    font-size: 1rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.forge {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: padding 0.35s ease;
}

body.chamber-active .forge {
    padding-right: clamp(1.25rem, 2vw, 1.5rem);
}

@media (min-width: 700px) {
    body.chamber-active .forge {
        padding-right: clamp(10rem, 22vw, 13rem);
    }
}

/* Panels */
.panel {
    background: linear-gradient(145deg, rgba(18, 8, 31, 0.92), rgba(10, 6, 18, 0.95));
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 1.75rem;
    box-shadow:
        inset 0 1px 0 rgba(61, 255, 138, 0.08),
        0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.panel-glyph {
    color: var(--gold);
    font-size: 1.25rem;
}

.panel h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: #d4c4a0;
    letter-spacing: 0.08em;
}

.panel-lead {
    margin: 0 0 1.25rem;
    color: rgba(184, 212, 190, 0.75);
    font-size: 1.05rem;
}

.field-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

/* Intent input */
.intent-input {
    width: 100%;
    padding: 1rem 1.1rem;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--phosphor);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.intent-input:focus {
    outline: none;
    border-color: var(--phosphor-dim);
    box-shadow: var(--glow-green);
}

.intent-input.shake {
    animation: input-shake 0.4s ease;
}

@keyframes input-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.field-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: rgba(184, 212, 190, 0.45);
}

.processed-preview {
    color: var(--phosphor-dim);
}

/* Method cards */
.method-fieldset {
    border: none;
    margin: 1.5rem 0 0;
    padding: 0;
}

.method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

@media (max-width: 520px) {
    .method-grid { grid-template-columns: 1fr; }
}

.method-card {
    cursor: pointer;
}

.method-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.method-card__inner {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(201, 162, 39, 0.15);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    height: 100%;
}

.method-card__inner strong {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: #d4c4a0;
    letter-spacing: 0.05em;
}

.method-card__inner small {
    font-size: 0.78rem;
    color: rgba(184, 212, 190, 0.55);
    line-height: 1.35;
}

.method-card input:checked + .method-card__inner,
.method-card__inner:hover {
    border-color: var(--border-gold);
    background: rgba(26, 10, 46, 0.6);
    box-shadow: var(--glow-gold);
}

.method-card input:checked + .method-card__inner {
    border-color: var(--phosphor-dim);
    box-shadow: var(--glow-green);
}

.method-card input:focus-visible + .method-card__inner {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Sliders */
.controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin: 1.5rem 0;
}

@media (max-width: 520px) {
    .controls-row { grid-template-columns: 1fr; }
}

.slider-group {
    display: flex;
    flex-direction: column;
}

.occult-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--violet-deep), var(--phosphor-dim));
    border-radius: 2px;
    outline: none;
    margin: 0.5rem 0 0.25rem;
}

.occult-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--gold), #6b4f12);
    border: 2px solid var(--phosphor-dim);
    cursor: pointer;
    box-shadow: var(--glow-gold);
}

.occult-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--gold), #6b4f12);
    border: 2px solid var(--phosphor-dim);
    cursor: pointer;
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: rgba(184, 212, 190, 0.4);
}

/* Buttons */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2.5rem;
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    border: 2px solid var(--phosphor-dim);
    background: rgba(5, 21, 5, 0.85);
    color: var(--phosphor);
    cursor: pointer;
    border-radius: 2px;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.btn:hover:not(:disabled) {
    background: rgba(10, 42, 10, 0.9);
    transform: scale(1.03);
    box-shadow: var(--glow-green);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn--primary {
    width: 100%;
    margin-top: 0.5rem;
    padding: 1.25rem;
    font-size: 1.15rem;
    border-width: 3px;
}

.btn--ghost {
    padding: 0.65rem 1.25rem;
    font-size: 0.8rem;
    border-width: 1px;
    background: transparent;
    color: rgba(184, 212, 190, 0.8);
}

.btn--small {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn--cast {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1.35rem;
    font-size: 1.2rem;
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(30, 20, 5, 0.7);
}

.btn--cast:hover:not(:disabled) {
    box-shadow: var(--glow-gold);
    background: rgba(50, 35, 10, 0.8);
}

.btn--pulse .btn-glow {
    position: absolute;
    inset: -2px;
    background: radial-gradient(ellipse at center, rgba(61, 255, 138, 0.15), transparent 70%);
    animation: btn-breathe 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes btn-breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Floating sigil companion — stays in view during gnosis & cast */
.sigil-companion {
    position: fixed;
    z-index: 6;
    opacity: 0.8;
    pointer-events: none;
    transition: opacity 0.45s ease;
}

.sigil-companion[hidden] {
    display: none !important;
}

/* Desktop: right edge, vertically centered — anchor never animates */
@media (min-width: 700px) {
    .sigil-companion {
        top: 50%;
        right: max(1rem, env(safe-area-inset-right, 1rem));
        transform: translateY(-50%);
    }
}

/* Mobile: top center, below header — keeps gnosis & cast clear */
@media (max-width: 699px) {
    .sigil-companion {
        top: max(5.5rem, calc(4.5rem + env(safe-area-inset-top, 0px)));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

/* Drift + 7 Hz shake live on the inner frame only — preserves anchor position */
.sigil-frame--companion {
    width: min(36vw, 168px);
    opacity: 1;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.75),
        0 0 24px rgba(34, 136, 34, 0.25);
    animation: companion-drift 7s ease-in-out infinite;
}

@keyframes companion-drift {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@media (min-width: 700px) {
    .sigil-frame--companion {
        width: min(18vw, 200px);
    }
}

/* Sigil chamber */
.sigil-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.sigil-frame {
    position: relative;
    width: min(88vw, 380px);
    aspect-ratio: 1;
    background:
        radial-gradient(ellipse at center, rgba(17, 34, 17, 0.9) 0%, rgba(0, 10, 0, 0.95) 70%),
        repeating-conic-gradient(from 0deg, transparent 0deg 30deg, rgba(61, 255, 138, 0.02) 30deg 31deg);
    border: 2px solid rgba(51, 51, 51, 0.8);
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(34, 136, 34, 0.2);
}

.sigil-frame__corners::before,
.sigil-frame__corners::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--gold);
    border-style: solid;
    opacity: 0.5;
}

.sigil-frame__corners::before {
    top: 8px; left: 8px;
    border-width: 2px 0 0 2px;
}

.sigil-frame__corners::after {
    bottom: 8px; right: 8px;
    border-width: 0 2px 2px 0;
}

.sigil-container {
    position: absolute;
    inset: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sigil-scanline {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.04) 3px,
        rgba(0, 0, 0, 0.04) 4px
    );
    pointer-events: none;
    animation: scan-drift 8s linear infinite;
}

@keyframes scan-drift {
    from { background-position: 0 0; }
    to { background-position: 0 40px; }
}

.sigil-caption {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--phosphor-dim);
    text-align: center;
    letter-spacing: 0.1em;
    margin: 0;
}

.chamber-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

/* Gnosis */
.gnosis-panel {
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--mist);
    scroll-margin-top: max(11rem, calc(9rem + env(safe-area-inset-top, 0px)));
}

@media (min-width: 700px) {
    .gnosis-panel {
        scroll-margin-top: 2rem;
    }
}

.gnosis-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--gold);
    margin: 0 0 0.5rem;
    letter-spacing: 0.1em;
}

.gnosis-lead {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    color: rgba(184, 212, 190, 0.65);
}

.gnosis-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.gnosis-tab {
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(201, 162, 39, 0.2);
    color: rgba(184, 212, 190, 0.6);
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s;
}

.gnosis-tab:hover,
.gnosis-tab.active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(30, 20, 5, 0.5);
}

.gnosis-display {
    position: relative;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--mist);
    border-radius: 2px;
}

.breath-orb {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--phosphor), var(--phosphor-dim));
    box-shadow: 0 0 30px rgba(61, 255, 138, 0.4);
    margin-bottom: 1rem;
    transition: transform 4s ease-in-out, opacity 4s ease-in-out;
}

.breath-orb--inhale {
    transform: scale(1.45);
    opacity: 1;
    transition-duration: 4s;
}

.breath-orb--hold {
    transform: scale(1.45);
    opacity: 0.85;
    transition-duration: 1.5s;
}

.breath-orb--exhale {
    transform: scale(0.75);
    opacity: 0.5;
    transition-duration: 4.5s;
}

.gnosis-prompt {
    text-align: center;
    font-style: italic;
    color: rgba(184, 212, 190, 0.8);
    margin: 0;
    max-width: 28ch;
}

.gnosis-timer {
    font-family: var(--font-mono);
    font-size: 2rem;
    color: var(--gold);
    margin: 0.5rem 0 0;
    letter-spacing: 0.2em;
}

.timer-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

.timer-input {
    width: 5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    color: var(--phosphor);
    font-family: var(--font-mono);
    font-size: 1rem;
}

.cast-warning {
    text-align: center;
    font-size: 0.85rem;
    font-style: italic;
    color: rgba(184, 212, 190, 0.45);
    margin: 0.75rem 0 0;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 2rem 1.25rem calc(2rem + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.link-btn {
    background: none;
    border: none;
    color: rgba(184, 212, 190, 0.5);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-style: italic;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
}

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

.support-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    font-family: var(--font-display);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    color: var(--phosphor);
    text-decoration: none;
    border: 2px solid var(--phosphor-dim);
    background: rgba(5, 21, 5, 0.85);
    border-radius: 2px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.support-link:hover {
    background: #112211;
    box-shadow: var(--glow-green);
    transform: scale(1.04);
}

.copyright {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: rgba(184, 212, 190, 0.3);
}

/* Lore overlay — full-screen intro veil on load */
.lore-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    padding:
        max(1.25rem, env(safe-area-inset-top))
        max(1rem, env(safe-area-inset-right))
        max(1.25rem, env(safe-area-inset-bottom))
        max(1rem, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(0, 0, 0, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #b8d4be;
    animation: lore-fade-in 0.35s ease-out;
}

.lore-overlay[hidden] {
    display: none !important;
}

@keyframes lore-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

body.lore-open {
    overflow: hidden;
}

body.lore-open .app-root {
    visibility: hidden;
    pointer-events: none;
}

.lore-overlay__panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0;
    flex-shrink: 0;
    padding: 2rem 1.75rem;
    background: linear-gradient(160deg, rgba(18, 8, 31, 0.97), rgba(10, 6, 18, 0.98));
    border: 1px solid var(--border-gold);
    border-radius: 2px;
    box-shadow: 0 0 60px rgba(201, 162, 39, 0.08);
}

.lore-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--ash);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
}

.lore-close:hover { color: var(--gold); }

.lore-overlay h2 {
    font-family: var(--font-display);
    color: #d4c4a0;
    font-size: 1.4rem;
    margin: 0 0 1rem;
    padding-right: 2rem;
}

.lore-overlay h3 {
    font-family: var(--font-display);
    color: var(--gold);
    font-size: 1rem;
    margin: 1.25rem 0 0.5rem;
}

.lore-overlay p,
.lore-overlay li {
    font-size: 1rem;
    color: rgba(184, 212, 190, 0.85);
}

.lore-overlay ol,
.lore-overlay ul {
    padding-left: 1.25rem;
}

.lore-closing {
    font-style: italic;
    margin-top: 1.25rem !important;
}

.lore-overlay .btn--primary {
    width: 100%;
    margin-top: 1.5rem;
}

/* Cast flash */
.flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    background: radial-gradient(circle, rgba(61, 255, 138, 0.4), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.flash-overlay--active,
.flash-overlay--cast {
    opacity: 1;
}

.flash-overlay--cast {
    background: radial-gradient(circle, rgba(201, 162, 39, 0.5), rgba(61, 255, 138, 0.2) 40%, transparent 75%);
    animation: cast-flash 1.4s ease-out forwards;
}

@keyframes cast-flash {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* SVG sigil styles */
.sigil-svg {
    display: block;
    filter: drop-shadow(0 0 8px rgba(34, 136, 34, 0.5));
}

.sigil-path {
    opacity: 0;
}

/* Touch targets */
@media (pointer: coarse) {
    .btn { min-height: 48px; }
    .gnosis-tab { min-height: 44px; padding: 0.65rem 1.1rem; }
    .method-card__inner { padding: 1rem; }
}

/* Large screens */
@media (min-width: 900px) {
    .forge {
        max-width: 780px;
    }

    .panel {
        padding: 2rem 2.25rem;
    }
}