/* Ramaweb widget, ramapani.com/page/ramaweb
   Everything is scoped under .rw-app so it sits cleanly inside the site styles.
   Colours follow the Ramaparticles family: night sky inside, paper and umber for panels. */

.rw-app {
    --rw-ink: #4b4032;
    --rw-umber: #8b5e3c;
    --rw-umber-deep: #6d4528;
    --rw-paper: #f6f2ea;
    --rw-paper-2: #ece5d8;
    --rw-line: #d9cfbd;
    --rw-glass: rgba(14, 16, 24, 0.6);
    --rw-glass-line: rgba(246, 242, 234, 0.16);
    --rw-icon: #f1e9db;
    --rw-moon: #e8ecf4;
    --rw-amber: #f2b766;
    --rw-sky: radial-gradient(120% 90% at 50% 18%, #18203a 0%, #0b1020 45%, #05070d 100%);

    container-type: inline-size;
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 420px;
    max-height: 86vh;
    margin: 1.5em 0;
    background: var(--rw-sky);
    border-radius: 12px;
    overflow: hidden;
    overflow: clip;
    box-shadow: 0 6px 24px rgba(40, 28, 16, 0.25);
    font-family: Georgia, serif;
    line-height: 1.4;
    color: var(--rw-ink);
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.rw-app.rw-bbc { --rw-sky: #000; }

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

/* Phones: a tall frame so the 3 x 3 grid can use the full width */
@media (max-width: 640px) {
    .rw-app { aspect-ratio: 4 / 5.4; max-height: 88vh; min-height: 0; border-radius: 10px; }
}

.rw-app:focus-visible { box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.6), 0 6px 24px rgba(40, 28, 16, 0.25); }

/* Embed and full screen layouts */
.rw-app.rw-embed,
.rw-app:fullscreen,
.rw-app.rw-fs {
    aspect-ratio: auto;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}
.rw-app.rw-embed { width: 100%; }
.rw-app::backdrop { background: #05070d; }
.rw-app.rw-fs { position: fixed; inset: 0; z-index: 2147483000; }
html.rw-lock, html.rw-lock body { overflow: hidden !important; }

/* Canvases */
.rw-canvas,
.rw-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.rw-overlay { touch-action: manipulation; }
.rw-app.rw-picking .rw-overlay { cursor: pointer; }
.rw-app.rw-idle .rw-overlay { cursor: none; }

/* Status line */
.rw-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 12px 16px 0;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.6s ease;
}
.rw-top p { margin: 0; font-size: 15px; color: rgba(232, 236, 244, 0.72); }
.rw-hint { font-style: italic; }
.rw-hint.rw-ask { color: var(--rw-amber); font-style: normal; }
.rw-gen { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rw-app.rw-bbc .rw-top p { font-family: "Courier New", ui-monospace, monospace; color: #3fd8dc; font-style: normal; }
.rw-app.rw-bbc .rw-hint.rw-ask { color: #ffd166; }
@container (max-width: 420px) {
    .rw-top { padding: 10px 12px 0; }
    .rw-top p { font-size: 13.5px; }
}

/* Contemplation line */
.rw-thought {
    position: absolute;
    left: 50%;
    bottom: 84px;
    transform: translateX(-50%);
    width: min(92%, 640px);
    margin: 0;
    text-align: center;
    font-style: italic;
    font-size: 17px;
    line-height: 1.5;
    color: rgba(232, 236, 244, 0.86);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 2.4s ease;
    pointer-events: none;
    z-index: 2;
}
.rw-thought.rw-on { opacity: 1; }
.rw-thought cite { display: block; margin-top: 4px; font-size: 13px; font-style: normal; color: rgba(232, 236, 244, 0.6); }
.rw-app.rw-idle .rw-thought { bottom: 28px; }
@container (max-width: 420px) { .rw-thought { font-size: 15px; } }

/* Control bar */
.rw-bar {
    position: absolute;
    left: 50%;
    bottom: 14px;
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--rw-glass);
    border: 1px solid var(--rw-glass-line);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    z-index: 3;
}
.rw-app.rw-idle .rw-bar,
.rw-app.rw-idle .rw-brand,
.rw-app.rw-idle .rw-top { opacity: 0; pointer-events: none; }
.rw-app.rw-idle .rw-bar { transform: translateX(-50%) translateY(8px); }

.rw-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: var(--rw-icon);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.rw-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.rw-btn svg [fill="none"] { fill: none; }
.rw-btn:hover { background: rgba(246, 242, 234, 0.14); }
.rw-btn:focus-visible { outline: 2px solid #e0c08f; outline-offset: 1px; }
.rw-btn[aria-pressed="true"],
.rw-btn-settings[aria-expanded="true"] { background: rgba(224, 192, 143, 0.28); color: #ffe7c2; }
.rw-btn .rw-i-play, .rw-btn .rw-i-unfs { display: none; }
.rw-app.rw-paused .rw-btn .rw-i-play { display: block; }
.rw-app.rw-paused .rw-btn .rw-i-pause { display: none; }
.rw-app:fullscreen .rw-btn .rw-i-fs, .rw-app.rw-fs .rw-btn .rw-i-fs { display: none; }
.rw-app:fullscreen .rw-btn .rw-i-unfs, .rw-app.rw-fs .rw-btn .rw-i-unfs { display: block; }
@container (max-width: 380px) {
    .rw-bar { gap: 2px; padding: 4px; }
    .rw-btn { width: 42px; height: 42px; }
}

.rw-brand {
    position: absolute;
    right: 14px;
    bottom: 26px;
    font-size: 12px;
    color: rgba(232, 236, 244, 0.42) !important;
    text-decoration: none !important;
    z-index: 2;
    transition: opacity 0.6s ease;
}
.rw-brand:hover { color: rgba(232, 236, 244, 0.8) !important; }
@container (max-width: 640px) { .rw-brand { display: none; } }

/* Drawer */
.rw-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 100%);
    background: var(--rw-paper);
    color: var(--rw-ink);
    border-left: 1px solid var(--rw-line);
    transform: translateX(102%);
    transition: transform 0.35s ease;
    z-index: 6;
    display: flex;
    flex-direction: column;
    user-select: text;
    -webkit-user-select: text;
}
.rw-app.rw-open .rw-drawer { transform: none; }
.rw-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--rw-line);
}
.rw-drawer-head h2 { margin: 0; font-size: 20px; font-weight: normal; color: var(--rw-umber); }
.rw-close {
    width: 40px; height: 40px;
    border: 0; border-radius: 50%;
    background: transparent;
    font-size: 26px; line-height: 1;
    color: var(--rw-ink);
    cursor: pointer;
}
.rw-close:hover { background: var(--rw-paper-2); }
.rw-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
}
.rw-group { padding: 12px 0; border-bottom: 1px solid var(--rw-line); }
.rw-group h3 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: normal;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--rw-umber-deep);
}
.rw-note { margin: 8px 0 0; font-size: 13.5px; color: #6a5d4b; }
.rw-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--rw-line);
    border-radius: 10px;
    background: var(--rw-paper-2);
}
.rw-seg3 { grid-template-columns: repeat(3, 1fr); }
.rw-seg button {
    font: inherit;
    font-size: 14px;
    padding: 8px 4px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--rw-ink);
    cursor: pointer;
}
.rw-seg button[aria-pressed="true"] { background: var(--rw-umber); color: var(--rw-paper); }
.rw-seg button:focus-visible,
.rw-close:focus-visible,
.rw-action:focus-visible { outline: 2px solid var(--rw-umber); outline-offset: 2px; }

.rw-genes { display: flex; flex-direction: column; gap: 12px; }
.rw-gene { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: baseline; }
.rw-gene .rw-gname { font-size: 14px; }
.rw-gene .rw-gval { font-size: 14px; color: var(--rw-umber-deep); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rw-track { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: var(--rw-paper-2); border: 1px solid var(--rw-line); }
.rw-band { position: absolute; top: -1px; bottom: -1px; min-width: 3px; border-radius: 4px; background: var(--rw-umber); transition: left 0.5s ease, width 0.5s ease; }
.rw-ends { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11.5px; color: #8a7c66; font-variant-numeric: tabular-nums; }
.rw-chart { width: 100%; height: 110px; display: block; }
.rw-app:not(.rw-natural) .rw-chart-group { display: none; }
.rw-app.rw-natural [data-show="artificial"],
.rw-app:not(.rw-natural) [data-show="natural"] { display: none; }

.rw-drawer dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13.5px; }
.rw-drawer dt { font-weight: bold; white-space: nowrap; }
.rw-drawer dd { margin: 0; }
.rw-drawer-foot p { margin: 14px 0 0; font-size: 13px; color: #6a5d4b; }
.rw-drawer-foot a { color: var(--rw-umber); }

/* Toast */
.rw-toast {
    position: absolute;
    left: 50%;
    top: 52px;
    transform: translateX(-50%) translateY(-6px);
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--rw-paper);
    color: var(--rw-ink);
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 7;
}
.rw-toast.rw-show { opacity: 1; transform: translateX(-50%); }

/* Photosensitivity notice */
.rw-warning {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.72);
    z-index: 8;
}
.rw-app.rw-warn .rw-warning { display: flex; }
.rw-app.rw-warn .rw-bar,
.rw-app.rw-warn .rw-top { display: none; }
.rw-warning-card {
    max-width: 440px;
    max-height: 100%;
    overflow-y: auto;
    padding: 20px 22px;
    border-radius: 12px;
    background: var(--rw-paper);
    color: var(--rw-ink);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    user-select: text;
    -webkit-user-select: text;
}
.rw-warning-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: normal; color: var(--rw-umber); }
.rw-warning-card p { margin: 0 0 10px; font-size: 14.5px; }
.rw-action {
    margin-top: 6px;
    font: inherit;
    font-size: 15px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--rw-umber);
    color: var(--rw-paper);
    cursor: pointer;
}
.rw-action:hover { background: var(--rw-umber-deep); }
@container (max-width: 420px) {
    .rw-warning-card { padding: 14px 16px; }
    .rw-warning-card p { font-size: 13.5px; }
}

/* Wrapper page helpers */
.rw-photo-note {
    margin: 0.6em 0 0;
    padding: 0.5em 0.8em;
    border-left: 4px solid #c2b8a3;
    background: #f4f1ec;
    font-size: 0.8em;
    border-radius: 4px;
}
.rw-launch { display: flex; flex-wrap: wrap; gap: 0.6em 1.4em; margin-top: 0.8em; }

@media (prefers-reduced-motion: reduce) {
    .rw-drawer, .rw-band, .rw-bar, .rw-thought, .rw-toast { transition: none; }
}
