/* ==========================================================================
   REMISI Pohon Harapan — Frontend styles
   Scene (background + tree + leaves), wind animation, reusable leaf modal,
   seed bar, text-list fallback, accessibility (prefers-reduced-motion).
   ========================================================================== */

.rph-wrap {
    --rph-height: 80vh;
    --rph-green: #5fa844;
    --rph-yellow: #d9b24a;
    --rph-ink: #2f3a2a;
    --rph-card-bg: #f7fbef;
    position: relative;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: inherit;
}

/* ----------------------------------------------------------------- Scene */
.rph-scene {
    position: relative;
    width: 100%;
    height: var(--rph-height);
    min-height: 420px;
    overflow: hidden;
    border-radius: 14px;
}

.rph-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    user-select: none;
    pointer-events: none;
}

/* The stage holds the tree + leaves and is the coordinate space for leaves.
   It keeps the tree aspect ratio (1200x1400) centered at the bottom. */
.rph-stage {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    height: 100%;
    aspect-ratio: 1200 / 1400;
    max-width: 100%;
    z-index: 1;
}

.rph-tree {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: bottom center;
    user-select: none;
    pointer-events: none;
    z-index: 1;
}

/* Layer that contains all the absolutely-positioned leaves */
.rph-leaves {
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* ----------------------------------------------------------------- Leaves */
.rph-leaf {
    position: absolute;
    /* left/top set inline by JS (percentages within the stage) */
    width: 6.5%;
    min-width: 32px;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0;
    cursor: pointer;
    transform-origin: bottom center;
    transform: translate(-50%, -50%) rotate(var(--rph-tilt, 0deg));
    transition: filter 0.25s ease, transform 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}

/* Inner wrapper carries the wind sway so the leaf base stays anchored */
.rph-leaf-inner {
    display: block;
    width: 100%;
    transform-origin: bottom center;
    animation: rph-sway var(--rph-sway-dur, 4s) ease-in-out var(--rph-sway-delay, 0s) infinite alternate;
}

.rph-leaf-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}

/* Filled leaves: full color + subtle glow so they stand out */
.rph-leaf-filled .rph-leaf-img {
    filter: drop-shadow(0 0 6px rgba(255, 246, 180, 0.55)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

/* Empty leaves: lighter / faded (per request, brighter via code) */
.rph-leaf-empty .rph-leaf-img {
    opacity: 0.55;
    filter: brightness(1.35) saturate(0.7) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}

.rph-leaf:hover,
.rph-leaf:focus-visible {
    outline: none !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    z-index: 50;
    filter: brightness(1.08);
    transform: translate(-50%, -50%) rotate(var(--rph-tilt, 0deg)) scale(1.18);
}

/* Accessible focus indicator via a soft glow (avoids the theme's red box) */
.rph-leaf:focus-visible .rph-leaf-img {
    filter: drop-shadow(0 0 5px #ffffff) drop-shadow(0 0 9px rgba(255, 255, 255, 0.85));
}

@keyframes rph-sway {
    from { transform: rotate(-8deg) translateX(-3px); }
    to   { transform: rotate(9deg) translateX(3px); }
}

/* ----------------------------------------------------------------- Loading */
.rph-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6;
    color: #2f3a2a;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(2px);
}
.rph-wrap.rph-ready .rph-loading { display: none; }

/* ----------------------------------------------------------------- Seed bar */
.rph-seedbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    text-align: center;
    border: 0 !important;
}

.rph-seed-btn {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0;
    cursor: pointer;
    width: 76px;
    height: 76px;
    transition: transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}
.rph-seed-btn:hover,
.rph-seed-btn:focus-visible {
    transform: translateY(-3px) scale(1.06);
    outline: none !important;
    border: 0 !important;
    box-shadow: none !important;
}
.rph-seed-btn:focus-visible .rph-seed-img {
    filter: drop-shadow(0 0 6px #fff) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.2));
}

.rph-seed-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.2));
    animation: rph-seed-bob 3s ease-in-out infinite alternate;
}
@keyframes rph-seed-bob {
    from { transform: translateY(0); }
    to   { transform: translateY(-5px); }
}

.rph-seed-label {
    font-size: 0.95rem;
    color: var(--rph-ink);
    font-weight: 600;
}

.rph-list-toggle {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--rph-green);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
    -webkit-appearance: none;
    appearance: none;
}
.rph-list-toggle:hover { color: var(--rph-ink); }

/* ----------------------------------------------------------------- Text list */
.rph-textlist {
    margin-top: 16px;
    padding: 16px 18px;
    background: var(--rph-card-bg);
    border-radius: 12px;
    border: 1px solid #e0e7d4;
}
.rph-textlist-title {
    margin: 0 0 10px;
    font-size: 1.1rem;
    color: var(--rph-ink);
}
.rph-textlist-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.rph-textlist-items li {
    padding: 10px 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #ebf0e2;
    color: #3a4633;
    font-size: 0.95rem;
    line-height: 1.5;
}
.rph-textlist-empty {
    color: #7d8a72;
    font-style: italic;
}

/* ----------------------------------------------------------------- Modal */
.rph-modal {
    --rph-green: #5fa844;
    --rph-yellow: #d9b24a;
    --rph-ink: #2f3a2a;
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.rph-modal[hidden] { display: none; }

.rph-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(30, 40, 24, 0.45);
    backdrop-filter: blur(4px);
    animation: rph-fade 0.2s ease;
    z-index: 0;
}
@keyframes rph-fade { from { opacity: 0; } to { opacity: 1; } }

/* Leaf card — a horizontal leaf image with white text centered on it (no panel) */
.rph-leaf-card {
    position: relative;
    z-index: 1;
    width: min(580px, 94vw);
    aspect-ratio: 1 / 1;
    max-height: 92vh;
    box-sizing: border-box;
    background: none;
    border: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: visible;
    animation: rph-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
    text-align: center;
}
@keyframes rph-pop {
    from { opacity: 0; transform: scale(0.6) rotate(-4deg); }
    to   { opacity: 1; transform: scale(1) rotate(0); }
}

/* The leaf picture: portrait art rotated 90deg → horizontal, filling the card */
.rph-leaf-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: rotate(90deg);
    pointer-events: none;
    user-select: none;
    z-index: 0;
    filter: drop-shadow(0 16px 28px rgba(20, 35, 15, 0.4));
}

/* Color accents driven by leaf color */
.rph-leaf-card.rph-card-green  { --rph-accent: var(--rph-green); }
.rph-leaf-card.rph-card-yellow { --rph-accent: var(--rph-yellow); }

/* Each mode: white text centered over the leaf, no background panel */
.rph-mode {
    position: relative;
    z-index: 2;
    width: 62%;
    max-height: 64%;
    overflow: hidden;
    box-sizing: border-box;
    background: none;
    box-shadow: none;
    padding: 0;
    color: #ffffff;
}
@media (max-width: 600px) {
    .rph-mode { width: 78%; max-height: 72%; }
}
.rph-mode[hidden] { display: none; }

/* Make all text on the leaf white and legible without a panel */
.rph-read-content,
.rph-empty-title,
.rph-empty-body,
.rph-write-title,
.rph-write-intro,
.rph-write-note,
.rph-grow-text {
    color: #ffffff !important;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55), 0 0 2px rgba(0, 0, 0, 0.4);
}

/* The abstract emblem is no longer needed now the leaf image shows */
.rph-leaf-emblem { display: none; }

/* Read mode */
.rph-read-content {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--rph-ink);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 6px 0 18px;
}
.rph-report-btn {
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translate(-50%, 100%);
    border: 0 !important;
    background: rgba(0, 0, 0, 0.32) !important;
    box-shadow: none !important;
    color: #ffffff;
    text-decoration: none;
    border-radius: 16px;
    padding: 6px 16px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    font-size: 0.85rem;
    z-index: 4;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}
.rph-report-btn[hidden] { display: none; }
.rph-report-btn:hover { background: rgba(0, 0, 0, 0.5) !important; color: #ffe9d8; }
.rph-report-btn[disabled] { color: #eef; cursor: default; opacity: 0.85; }

/* Empty mode */
.rph-empty-title {
    margin: 4px 0 6px;
    color: var(--rph-ink);
    font-size: 1.2rem;
}
.rph-empty-body {
    margin: 0 0 18px;
    color: #5b6852;
}
.rph-empty-fill,
.rph-write-submit {
    border: 0 !important;
    background: #5fa844 !important;
    box-shadow: none !important;
    color: #fff !important;
    font-weight: 600;
    padding: 11px 22px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 0.98rem;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}
.rph-empty-fill:hover,
.rph-write-submit:hover { background: #4d9136 !important; transform: translateY(-1px); }
.rph-empty-fill:focus-visible,
.rph-write-submit:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Write mode — fills the leaf with the prompt on top and the note at the bottom */
.rph-mode-write {
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    box-shadow: none;
    padding: 0;
}
.rph-write-top {
    width: 100%;
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    text-align: center;
    z-index: 10;
    pointer-events: auto;
}
.rph-write-mid {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8%;
}
.rph-write-bottom {
    width: 100%;
    position: absolute;
    bottom: -50%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    text-align: center;
    z-index: 10;
    pointer-events: auto;
}

.rph-write-title {
    margin: 0 0 4px;
    color: #ffffff;
    font-size: 1.45rem;
}
.rph-write-intro {
    margin: 0;
    color: #ffffff;
    font-size: 0.92rem;
    line-height: 1.45;
}
.rph-write-input {
    width: 100%;
    box-sizing: border-box;
    border: 0;
    background: transparent;
    padding: 0.8em 6px 0.5em;
    font-size: 1.5rem;
    font-family: inherit;
    line-height: 1.35;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    resize: none;
    overflow: hidden;
    height: 7.5em;
    max-height: 7.5em;
}
.rph-write-input::placeholder { color: rgba(255, 255, 255, 0.75); }
.rph-write-input:focus { outline: none; border: 0; box-shadow: none; }

.rph-write-counter {
    color: #ffffff;
    font-size: 0.82rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    opacity: 0.9;
}
.rph-write-note {
    margin: 10px 0 0;
    font-size: 0.74rem;
    line-height: 1.5;
}
.rph-write-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.rph-write-cancel {
    border: 2px solid #cdd9bc !important;
    background: #fff !important;
    box-shadow: none !important;
    color: #5b6852;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 0.98rem;
    -webkit-appearance: none;
    appearance: none;
}
.rph-write-cancel:hover { background: #f0f4e8; }

.rph-write-error {
    margin: 0 0 12px;
    color: #c0392b;
    font-size: 0.88rem;
    min-height: 1em;
}

/* Honeypot — visually hidden but reachable by bots */
.rph-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Growing mode */
.rph-mode-growing { padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: visible; }
.rph-grow-sprout {
    font-size: 2rem;
    display: block;
    margin: 0 auto;
    animation: rph-grow 0.9s ease;
}
@keyframes rph-grow {
    0%   { transform: scale(0) translateY(20px); opacity: 0; }
    60%  { transform: scale(1.25) translateY(0); opacity: 1; }
    100% { transform: scale(1); }
}
.rph-grow-text {
    margin: 8px 0 0;
    font-size: 1rem;
    color: #ffffff;
    font-weight: 600;
    animation: rph-fade 0.6s ease 0.3s both;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
    white-space: nowrap;
}

/* ----------------------------------------------------------------- Responsive */
@media (max-width: 600px) {
    .rph-scene { height: max(var(--rph-height), 60vh); }
    .rph-leaf { width: 12% !important; }
    .rph-leaf-card { padding: 18% 14%; }
    .rph-write-top { top: -15%; }
    .rph-write-bottom { bottom: -15%; }
}

/* ----------------------------------------------------------------- Info button & panel */
.rph-info-btn {
    position: fixed;
    bottom: 22px;
    left: 22px;
    z-index: 50;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 0 !important;
    background: #5fa844 !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    color: #ffffff !important;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.rph-info-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(95, 168, 68, 0.3);
}

.rph-info-panel {
    position: fixed;
    bottom: 70px;
    left: 22px;
    z-index: 60;
    width: min(320px, 85vw);
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    animation: rph-fade 0.2s ease;
}
.rph-info-panel[hidden] { display: none; }

.rph-info-title {
    margin: 0 0 12px;
    font-size: 1.05rem;
    color: #2f3a2a;
    font-weight: 700;
}
.rph-info-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rph-info-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #3a4633;
    line-height: 1.4;
}
.rph-info-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.rph-info-leaf-bright {
    width: 20px;
    height: 20px;
    background: #5fa844;
    border-radius: 50% 0;
    transform: rotate(45deg);
}
.rph-info-leaf-faded {
    width: 20px;
    height: 20px;
    background: #5fa844;
    border-radius: 50% 0;
    transform: rotate(45deg);
    opacity: 0.4;
}
.rph-info-seed-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}
.rph-info-close {
    margin-top: 14px;
    border: 0 !important;
    background: #5fa844 !important;
    color: #fff !important;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.88rem;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none !important;
}
.rph-info-close:hover { background: #4d9136 !important; }

@media (max-width: 600px) {
    .rph-info-btn { bottom: 16px; left: 16px; width: 34px; height: 34px; font-size: 1rem; }
    .rph-info-panel { bottom: 58px; left: 16px; }
}

/* ----------------------------------------------------------------- Toast */
.rph-toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 40, 24, 0.92);
    color: #fff;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center;
    max-width: 88vw;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.rph-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ----------------------------------------------------------------- Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .rph-leaf-inner,
    .rph-seed-img { animation: none !important; }
    .rph-leaf-card,
    .rph-grow-sprout,
    .rph-grow-text,
    .rph-modal-backdrop { animation: none !important; }
    .rph-leaf { transition: none; }
}
