/* ==================================================================
   RAMANDALA (2.0.0)   ramapani.com/page/mandala
   The mandala sits on a stage (.md-stage) that takes its colour from
   the mandala's own ground. The buttons, the caption and the settings
   drawer float over it, so all of it goes full screen together.
   Three layouts: .md-is-page (inside the site), .md-is-play (filling
   the window) and .md-is-embed (inside an iframe on another site).
================================================================== */
.md-app {
    --md-glass: rgba(16, 14, 22, 0.58);
    --md-glass-line: rgba(255, 255, 255, 0.22);
    --md-ink: #4b4032;            /* the site's text colour */
    --md-accent: #8b5e3c;         /* the site's link colour */
    --md-paper: #fdfcf9;          /* the site's page colour */
    --md-soft: #f4f1ec;
    margin: 1rem 0 1.5rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}
.md-app [hidden] { display: none !important; }

.md-stage {
    position: relative;
    width: 100%;
    height: clamp(360px, 82vh, 820px);
    overflow: hidden;
    background: #14100c;
    transition: background-color 1.2s ease;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.md-stage:focus-visible { box-shadow: inset 0 0 0 3px #f5cf2e; }
.md-is-play .md-stage, .md-is-embed .md-stage { position: fixed; inset: 0; height: auto; }
.md-is-play, .md-is-embed { margin: 0; }
.md-is-play .md-bar, .md-is-embed .md-bar { bottom: 30px; }
.md-is-play .md-art, .md-is-embed .md-art { bottom: 92px; }
.md-is-play .md-toast, .md-is-embed .md-toast { bottom: 98px; }
.md-stage:fullscreen, .md-stage.md-fullpage { height: 100vh; height: 100dvh; }
.md-stage.md-fullpage { position: fixed; inset: 0; z-index: 100000; }
html.md-noscroll, html.md-noscroll body { overflow: hidden; }

/* ---- the mandala: two drawings, one fading in over the other ---- */
/* the art stops short of the buttons, so the mandala is never hidden behind them */
.md-art { position: absolute; inset: 10px 10px 78px; }
.md-svg {
    position: absolute; inset: 0; width: 100%; height: 100%; display: block;
    opacity: 0; transition: opacity 1.2s ease;
}
.md-svg.md-on { opacity: 1; }
.md-quick .md-svg, .md-quick.md-stage { transition: none; }
.md-turn .md-art { animation: md-turn 360s linear infinite; }
@keyframes md-turn { to { transform: rotate(360deg); } }

/* ---- caption, top left ---- */
.md-caption {
    position: absolute; top: 12px; left: 12px; right: 12px; margin: 0;
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
    pointer-events: none; z-index: 2;
    transition: opacity 0.6s ease;
}
.md-cap-title, .md-cap-sub {
    padding: 4px 12px; border-radius: 999px;
    background: var(--md-glass); color: #fff;
    font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.md-cap-sub { font-weight: 400; color: rgba(255, 255, 255, 0.88); }
.md-cap-title:empty, .md-cap-sub:empty { display: none; }

/* ---- messages, above the buttons ---- */
.md-toast {
    position: absolute; left: 50%; bottom: 84px; transform: translate(-50%, 8px);
    max-width: min(440px, calc(100% - 32px)); margin: 0; padding: 10px 18px;
    border-radius: 14px; background: rgba(253, 252, 249, 0.96); color: var(--md-ink);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    font-size: 14px; text-align: center;
    opacity: 0; pointer-events: none; z-index: 4;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.md-toast.md-show { opacity: 1; transform: translate(-50%, 0); }
.md-noscript { position: absolute; inset: 40% 16px auto; margin: 0; color: #fff; text-align: center; }

/* ---- the row of buttons ---- */
.md-bar {
    position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
    display: flex; gap: 6px; padding: 7px;
    border-radius: 999px; background: var(--md-glass); border: 1px solid var(--md-glass-line);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 3;
    transition: opacity 0.6s ease;
}
.md-btn {
    display: grid; place-items: center;
    width: 44px; height: 44px; padding: 0; margin: 0;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, 0.10); color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}
.md-btn:hover { background: rgba(255, 255, 255, 0.24); }
.md-btn:active { transform: scale(0.94); }
.md-btn:focus-visible, .md-close:focus-visible, .md-seg button:focus-visible, .md-select:focus-visible { outline: 3px solid #f5cf2e; outline-offset: 2px; }
.md-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.md-btn svg [fill="none"] { fill: none; }
.md-btn-main { background: rgba(255, 255, 255, 0.92); color: #2a2018; }
.md-btn-main:hover { background: #fff; }
.md-btn-like svg path { fill: none; }
.md-btn-like.md-liked { color: #ff7a9c; }
.md-btn-like.md-liked svg path { fill: currentColor; }
.md-btn-like.md-spent { opacity: 0.45; }
.md-btn[disabled] { opacity: 0.35; cursor: default; }

/* which of two icons shows */
.md-i-pause, .md-i-unfs { display: none; }
.md-playing .md-i-play, .md-full .md-i-fs { display: none; }
.md-playing .md-i-pause, .md-full .md-i-unfs { display: block; }

/* while a mandala is being watched and nothing is touched, the controls step back */
.md-idle .md-bar, .md-idle .md-caption, .md-idle .md-brand { opacity: 0; }
.md-idle { cursor: none; }
.md-bar:focus-within { opacity: 1 !important; }

.md-brand {
    position: absolute; left: 0; right: 0; bottom: 8px; text-align: center;
    font-size: 11px; color: rgba(255, 255, 255, 0.75); text-decoration: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); z-index: 2;
    transition: opacity 0.6s ease;
}
.md-brand:hover { color: #fff; text-decoration: underline; }

/* ---- the settings drawer: the site's own paper and ink ---- */
.md-drawer {
    position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 100%);
    display: flex; flex-direction: column;
    background: var(--md-paper); color: var(--md-ink);
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 5; user-select: text; -webkit-user-select: text;
    animation: md-slide 0.25s ease;
}
@keyframes md-slide { from { transform: translateX(24px); opacity: 0; } }
.md-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 10px 10px 18px; border-bottom: 1px solid #e0ddd7; background: var(--md-soft);
}
.md-drawer-head h2 { margin: 0; font-family: Georgia, serif; font-size: 20px; font-weight: normal; color: #5a4e3c; }
.md-close {
    width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: var(--md-ink); font-size: 26px; line-height: 1; cursor: pointer;
}
.md-close:hover { background: rgba(0, 0, 0, 0.08); }
.md-drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 18px 18px; overscroll-behavior: contain; }
.md-group { padding: 14px 0 12px; border-bottom: 1px solid #ebe7df; }
.md-group h3 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 16px; font-weight: normal; color: var(--md-accent); }
.md-note { margin: 8px 0 0; font-size: 13px; color: #6d6253; }
.md-foot { padding-top: 12px; }

.md-seg { display: flex; gap: 0; margin-top: 8px; border: 1px solid #c2b8a3; border-radius: 10px; overflow: hidden; }
.md-seg button {
    flex: 1 1 0; min-height: 40px; padding: 6px 8px; margin: 0;
    border: 0; border-left: 1px solid #c2b8a3; background: #fff; color: var(--md-ink);
    font: inherit; font-size: 14px; cursor: pointer;
}
.md-seg button:first-child { border-left: 0; }
.md-seg button:hover { background: var(--md-soft); }
.md-seg button[aria-pressed="true"] { background: var(--md-accent); color: #fffaf2; }

.md-select {
    width: 100%; min-height: 40px; padding: 6px 10px; box-sizing: border-box;
    border: 1px solid #c2b8a3; border-radius: 10px; background: #fff; color: var(--md-ink);
    font: inherit; font-size: 15px;
}
.md-field { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; }
.md-keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.md-keys dt { font-weight: 600; white-space: nowrap; }
.md-keys dd { margin: 0; color: #6d6253; }

/* ---- the words around the app on the page ---- */
.md-photo-note { font-size: 0.85em; }
.md-launch { display: flex; flex-wrap: wrap; gap: 8px 22px; }

/* the colouring books card: picture beside words, the whole card one link */
.md-book {
    display: flex; align-items: center; gap: 1.2em;
    max-width: 820px; margin: 1.5em 1em; padding: 1em;
    background: #fff; color: inherit; text-decoration: none;
    border-radius: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.md-book img { flex: 0 0 auto; width: 220px; height: auto; border-radius: 8px; display: block; }
.md-book-text { display: flex; flex-direction: column; gap: 0.35em; min-width: 0; }
.md-book-kicker { font-size: 0.8em; letter-spacing: 0.04em; text-transform: uppercase; color: #8b5e3c; }
.md-book-title { font-size: 1.1em; line-height: 1.3; }
.md-book-words { font-size: 0.85em; line-height: 1.5; }
.md-book-more { align-self: flex-start; margin-top: 0.3em; padding: 6px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.05); color: #8b5e3c; font-size: 0.85em; font-weight: bold; }
.md-book:hover .md-book-more, .md-book:focus-visible .md-book-more { background: rgba(0, 0, 0, 0.12); color: #6d4528; }
.md-book:focus-visible { outline: 3px solid #f5cf2e; outline-offset: 3px; }
@media (hover: hover) { .md-book:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12); } }
@media (max-width: 600px) {
    .md-book { flex-direction: column; text-align: center; margin: 1.5em 0.6em; }
    .md-book img { width: min(260px, 70%); }
    .md-book-more { align-self: center; }
}

/* ---- small screens ---- */
@media (max-width: 520px) {
    .md-stage { height: clamp(340px, 76vh, 640px); }
    .md-bar { gap: 3px; padding: 5px; bottom: 12px; }
    .md-btn { width: 38px; height: 38px; }
    .md-btn svg { width: 20px; height: 20px; }
    .md-art { inset: 8px 6px 66px; }
    .md-is-play .md-art, .md-is-embed .md-art { bottom: 84px; }
    .md-btn-today { display: none; }             /* still there as "Days" in the settings */
    .md-toast { bottom: 72px; }
}
@media (max-width: 350px) {
    .md-btn { width: 34px; height: 34px; }
}

/* people who have asked their device for less movement get no turning and no fades */
@media (prefers-reduced-motion: reduce) {
    .md-turn .md-art { animation: none; }
    .md-svg, .md-stage, .md-drawer { transition: none; animation: none; }
}
