/*
  DeepeningShell
  Dos documentos independientes: lectura biblica y cuaderno de meditacion.
*/

#deepening-root[hidden] {
    display: none !important;
}

#deepening-root {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: var(--deepening-shell-height, 100dvh);
    z-index: 1600;
    background: #f5f1e8;
    color: #2f261f;
    overflow: hidden;
    box-sizing: border-box;
}

html.deepening-shell-active,
body.deepening-shell-active {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.deepening-shell-active > header,
body.deepening-shell-active > #app-content,
body.deepening-shell-active > .bottom-nav {
    display: none !important;
}

.deepening-shell {
    --deepening-reading-top: calc(8px + env(safe-area-inset-top));
    --deepening-page-gutter: clamp(20px, 5.6vw, 62px);
    --deepening-mobile-gutter: clamp(18px, 5vw, 24px);
    position: relative;
    width: 100%;
    height: var(--deepening-layout-height, 100%);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: minmax(0, 1.36fr) minmax(0, 0.64fr);
    gap: 0;
    padding: clamp(8px, 2.2vw, 16px);
    background:
        radial-gradient(circle at 50% -18%, rgba(255, 255, 255, 0.34), transparent 34%),
        #f5f1e8;
    overscroll-behavior: none;
    touch-action: pan-y;
    box-sizing: border-box;
    transition: grid-template-rows 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.deepening-shell.is-keyboard-open {
    grid-template-rows: minmax(0, 1.2fr) minmax(0, 0.8fr);
}

.deepening-reading-host,
.deepening-meditation-host {
    display: contents;
}

.deepening-reading-document {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    padding:
        var(--deepening-reading-top)
        var(--deepening-page-gutter)
        30px;
    touch-action: pan-y;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 36%),
        #f8f4ec;
    border: 1px solid rgba(72, 56, 37, 0.012);
    border-radius: 22px 22px 12px 12px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.26),
        inset 0 -30px 46px rgba(47, 38, 31, 0.018);
    box-sizing: border-box;
}

.deepening-reading {
    max-width: 660px;
    margin: 0 auto;
    padding-bottom: 32px;
}

.deepening-reading-toolbar {
    position: sticky;
    top: calc(-1 * var(--deepening-reading-top));
    z-index: 2;
    max-width: 660px;
    margin: 0 auto clamp(8px, 1.8vh, 14px);
    padding: 0 0 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(248, 244, 236, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(72, 56, 37, 0.055);
}

.deepening-reading-toolbar-main {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.deepening-reading-toolbar-actions {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.deepening-reading-version-selector {
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.deepening-reading-version-option,
.deepening-reading-listen {
    min-width: 44px;
    min-height: 31px;
    padding: 0 9px;
    border: 1px solid rgba(72, 56, 37, 0.055);
    border-radius: 999px;
    background: rgba(245, 241, 232, 0.68);
    color: rgba(47, 38, 31, 0.62);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.7rem;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0;
    cursor: pointer;
}

.deepening-reading-voice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.deepening-reading-listen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 38px;
    min-width: 38px;
    min-height: 31px;
    padding: 0;
    border-color: rgba(72, 56, 37, 0.05);
    background: transparent;
    color: rgba(47, 38, 31, 0.54);
    font-weight: 600;
}

.deepening-reading-listen-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.deepening-reading-listen.is-speaking {
    background: #2f261f;
    border-color: #2f261f;
    color: #f8f4ec;
}

.deepening-reading-voice-stop {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(72, 56, 37, 0.055);
    border-radius: 999px;
    background: rgba(245, 241, 232, 0.74);
    color: rgba(47, 38, 31, 0.6);
    cursor: pointer;
}

.deepening-reading-voice-stop span {
    display: block;
    width: 10px;
    height: 10px;
    margin: auto;
    border-radius: 2px;
    background: currentColor;
}

.deepening-reading-version-option:hover,
.deepening-reading-listen:hover,
.deepening-reading-voice-stop:hover {
    border-color: rgba(184, 154, 99, 0.22);
    background: rgba(248, 244, 236, 0.92);
}

.deepening-reading-version-option:active,
.deepening-reading-listen:active,
.deepening-reading-voice-stop:active {
    transform: translate3d(0, 1px, 0);
}

.deepening-reading-version-option.is-active {
    background: #2f261f;
    color: #f8f4ec;
    border-color: #2f261f;
}

.deepening-reading-reference {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    max-width: 100%;
    font-size: clamp(0.84rem, 3.2vw, 1rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    color: #b89a63;
    text-align: center;
    text-wrap: balance;
}

.deepening-reading-text {
    max-width: 580px;
    margin: 0 auto;
    font-family: "Merriweather", Georgia, serif;
    font-size: clamp(1.08rem, 4vw, 1.24rem);
    line-height: 1.98;
    color: #2f261f;
    text-wrap: pretty;
}

.deepening-reading-text p {
    margin: 0 0 1.42em;
}

.deepening-reading-text .verse-item {
    transition:
        background-color 170ms ease,
        box-shadow 170ms ease,
        transform 170ms ease;
}

.deepening-reading-text .verse-item.deepening-active-verse {
    background-color: rgba(184, 154, 99, 0.145);
    box-shadow:
        inset 0 0 0 1px rgba(184, 154, 99, 0.18),
        0 10px 28px rgba(72, 56, 37, 0.048);
    border-radius: 12px;
}

.deepening-reading-text .verse-text-content,
.deepening-reading-text .verse-container {
    line-height: inherit;
}

.deepening-reading-text .verse-number {
    color: #b89a63;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.72em;
    font-weight: 650;
    letter-spacing: 0;
    opacity: 0.82;
}

.deepening-meditation-document {
    --deepening-notebook-line-height: 1.62em;
    --deepening-notebook-line-offset: 18px;
    position: relative;
    min-width: 0;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    padding:
        0
        clamp(18px, 5vw, 48px)
        calc(24px + env(safe-area-inset-bottom))
        clamp(18px, 5vw, 48px);
    margin-top: clamp(-18px, -2.8vh, -10px);
    background:
        radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.28), transparent 28%),
        linear-gradient(90deg, rgba(122, 83, 48, 0.035), transparent 42px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 46%),
        #f8f3e7;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 28px 28px 20px 20px;
    box-shadow:
        0 -20px 48px rgba(255, 255, 255, 0.24),
        0 -8px 24px rgba(47, 38, 31, 0.024),
        0 34px 84px rgba(42, 34, 24, 0.1),
        0 8px 24px rgba(42, 34, 24, 0.035),
        inset 22px 0 28px rgba(85, 65, 42, 0.018),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -1px 0 rgba(47, 38, 31, 0.018);
    backdrop-filter: blur(4px) saturate(1.01);
    transition: opacity 180ms ease;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.deepening-meditation-document.deepening-scroll-cue-visible {
    scrollbar-color: rgba(184, 154, 99, 0.42) transparent;
}

.deepening-meditation-document::-webkit-scrollbar {
    width: 4px;
}

.deepening-meditation-document::-webkit-scrollbar-track {
    background: transparent;
}

.deepening-meditation-document::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 999px;
}

.deepening-meditation-document.deepening-scroll-cue-visible::-webkit-scrollbar-thumb {
    background-color: rgba(184, 154, 99, 0.42);
}

.deepening-meditation-header {
    min-height: calc(42px + env(safe-area-inset-top));
    padding: calc(4px + env(safe-area-inset-top)) 0 4px;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 8px;
    border-bottom: 0;
    box-shadow: 0 10px 18px rgba(42, 34, 24, 0.014);
    user-select: none;
}

.deepening-meditation-grabber {
    position: absolute;
    top: calc(4px + env(safe-area-inset-top));
    left: 50%;
    width: 26px;
    height: 3px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(184, 154, 99, 0.38);
}

.deepening-meditation-title {
    grid-column: 2;
    margin: 3px 0 0;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: clamp(1.22rem, 4.4vw, 1.62rem);
    font-weight: 520;
    line-height: 1.1;
    text-align: center;
    letter-spacing: 0;
    color: #2f261f;
}

.deepening-meditation-close {
    grid-column: 3;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 2px 0 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(47, 38, 31, 0.5);
    font-size: 1.42rem;
    line-height: 1;
    cursor: pointer;
}

.deepening-meditation-close:focus-visible,
.deepening-reading-version-option:focus-visible,
.deepening-reading-listen:focus-visible,
.deepening-reading-voice-stop:focus-visible {
    outline: 2px solid rgba(49, 130, 206, 0.9);
    outline-offset: 2px;
}

.deepening-meditation-frame {
    position: relative;
    width: min(100%, 620px);
    margin: 0 auto;
    padding: clamp(12px, 2.8vw, 18px) clamp(16px, 4vw, 28px) clamp(18px, 4vw, 30px) clamp(20px, 4.4vw, 34px);
    border-radius: 18px;
    background:
        linear-gradient(90deg, transparent 0, transparent 10px, rgba(171, 67, 62, 0.34) 10px, rgba(171, 67, 62, 0.34) 11px, transparent 11px),
        linear-gradient(rgba(184, 154, 99, 0.052) 1px, transparent 1px)
        0 var(--deepening-notebook-line-offset) / 100% var(--deepening-notebook-line-height),
        radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.24), transparent 28%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 52%),
        #fbf6e9;
    box-shadow:
        0 18px 38px rgba(42, 34, 24, 0.045),
        inset 0 1px 0 rgba(255, 255, 255, 0.54),
        inset 18px 0 28px rgba(98, 72, 46, 0.018);
    box-sizing: border-box;
}

.deepening-step-list {
    display: flex;
    align-items: stretch;
    position: relative;
    gap: 7px;
    margin: -1px -4px 16px;
    padding: 3px 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}

.deepening-step-list::-webkit-scrollbar {
    display: none;
}

.deepening-step {
    position: relative;
    flex: 0 0 auto;
    min-width: max-content;
    min-height: 36px;
    padding: 6px 12px 7px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-bottom-color: rgba(184, 154, 99, 0.08);
    border-radius: 11px 11px 4px 4px;
    background: rgba(245, 241, 232, 0.46);
    color: rgba(47, 38, 31, 0.54);
    font: inherit;
    text-align: center;
    opacity: 0.72;
    box-shadow: inset 0 -7px 12px rgba(56, 45, 32, 0.018);
    scroll-snap-align: start;
    transition:
        background-color 170ms ease,
        border-color 170ms ease,
        color 170ms ease,
        opacity 180ms ease,
        transform 190ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.deepening-step:hover {
    background: rgba(248, 244, 236, 0.62);
    border-color: rgba(184, 154, 99, 0.16);
    color: rgba(47, 38, 31, 0.76);
    opacity: 0.82;
}

.deepening-step:active {
    transform: translate3d(0, 1px, 0);
}

.deepening-step:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.deepening-step.is-active {
    z-index: 1;
    background: rgba(184, 154, 99, 0.18);
    border-color: rgba(184, 154, 99, 0.22);
    border-bottom-color: rgba(184, 154, 99, 0.18);
    color: #2f261f;
    opacity: 1;
    transform: translate3d(0, -3px, 0);
    box-shadow:
        0 -2px 7px rgba(42, 34, 24, 0.02),
        inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.deepening-step.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -9px;
    height: 1px;
    border-radius: 999px;
    background: transparent;
}

.deepening-step:focus-visible {
    outline: 2px solid rgba(49, 130, 206, 0.9);
    outline-offset: 2px;
}

.deepening-step-kicker {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.64rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    color: rgba(122, 110, 99, 0.42);
}

.deepening-step.is-active .deepening-step-kicker {
    color: rgba(184, 154, 99, 0.72);
}

.deepening-step.is-active .deepening-step-label {
    font-weight: 600;
}

.deepening-step-label {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: clamp(0.72rem, 2.4vw, 0.84rem);
    font-weight: 500;
    line-height: 1.2;
}

.deepening-prompt {
    padding-top: 2px;
}

.deepening-prompt[hidden] {
    display: none !important;
}

.deepening-prompt h2 {
    margin: 0 0 10px;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: clamp(1.54rem, 5.6vw, 2.18rem);
    font-weight: 520;
    line-height: 1.08;
    letter-spacing: 0;
    color: #2f261f;
}

.deepening-prompt p {
    max-width: 36rem;
    margin: 0 0 8px;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.84rem;
    line-height: 1.44;
    color: #7a6e63;
}

.deepening-writing-area {
    width: 100%;
    min-height: 96px;
    padding: 0 0 calc(var(--deepening-notebook-line-height) * 0.72);
    border: 0;
    background: transparent;
    color: #2f261f;
    font-family: "Merriweather", Georgia, serif;
    font-size: 1rem;
    line-height: var(--deepening-notebook-line-height);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow: visible;
}

.deepening-writing-area:empty::before {
    content: attr(data-placeholder);
    color: rgba(31, 27, 22, 0.32);
    pointer-events: none;
}

.deepening-writing-area:focus {
    outline: none;
}

.deepening-dev-chip {
    min-height: 34px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(54, 47, 39, 0.1);
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.62);
    color: rgba(31, 27, 22, 0.58);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
}

.deepening-dev-chip-muted {
    color: rgba(31, 27, 22, 0.42);
}

@media (max-width: 520px) {
    .deepening-shell {
        --deepening-reading-top: calc(6px + env(safe-area-inset-top));
        --deepening-page-gutter: var(--deepening-mobile-gutter);
        grid-template-rows: minmax(0, 1.34fr) minmax(0, 0.66fr);
        gap: 0;
        padding: 8px;
    }

    .deepening-shell.is-keyboard-open {
        grid-template-rows: minmax(0, 1.2fr) minmax(0, 0.8fr);
    }

    .deepening-reading-document {
        border-radius: 22px 22px 12px 12px;
        padding-bottom: 28px;
    }

    .deepening-reading-toolbar {
        margin-bottom: 8px;
    }

    .deepening-reading-version-option {
        min-width: 38px;
        min-height: 31px;
        padding-inline: 8px;
    }

    .deepening-meditation-document {
        margin-top: -14px;
        padding: 0 10px calc(20px + env(safe-area-inset-bottom)) 10px;
        border-radius: 26px 26px 18px 18px;
    }

    .deepening-meditation-frame {
        padding: 12px 12px 20px 20px;
    }

    .deepening-step-list {
        gap: 3px;
        margin-bottom: 14px;
    }

    .deepening-step {
        min-height: 36px;
        padding-inline: 7px;
    }

    .deepening-step-kicker {
        display: none;
    }
}

@media (max-width: 360px) {
    .deepening-step-list {
        gap: 2px;
        margin-left: -8px;
        margin-right: -4px;
        padding-left: 0;
        padding-right: 0;
    }

    .deepening-step {
        padding-inline: 5px;
    }
}

@media (min-width: 521px) {
    .deepening-reading-toolbar-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

@media (min-width: 760px) {
    .deepening-shell {
        grid-template-rows: minmax(0, 1.3fr) minmax(0, 0.7fr);
    }
}

@media (min-width: 900px) {
    .deepening-meditation-document {
        border-radius: 20px;
    }
}

@supports not (height: 100dvh) {
    .deepening-shell {
        height: 100vh;
    }
}
