/* ========================================
   RENUMERA - Main Stylesheet
   ======================================== */

/* ---------- Global Reset ---------- */

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

:root {
    --bg: #8ccbc2;
    --text-color: #173b70;
    --primary: #173b70;
    --secondary: #2980b9;
    --white: #ffffff;
    --light-bg: #f8fafc;
    --border-color: #e1e8ed;
    --scrollbar-bg: #e2e8f0;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---------- Body ---------- */

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Plus Jakarta Sans', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text-color);
    text-align: center;
    position: relative;
    overflow-x: hidden;
}

/* ---------- Main Layout ---------- */
main {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* Change from space-between to avoid excessive middle gaps */
    align-items: stretch;
    width: 100%;
    max-width: 768px;
    min-height: 100vh;
    min-height: 100dvh;
    margin-inline: auto;
    padding: 12px;
    gap: 12px;
    /* Consistent spacing between sections */
    box-sizing: border-box;
}

/* Ensure content wrapper fills the middle flexibly */
#content,
.content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    /* Allows it to take up the remaining central space */
    width: 100%;
    min-height: 0;
    z-index: 2;
    /* Prevents overflow clipping */
}

#content iframe,
#content .dynamic-content {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none;
    /* Tambahan Background & Border */
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: clamp(16px, 2.5vh, 24px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

/* Upper and Lower structural wrappers */
#upper,
#lower {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex-shrink: 0;
}

#upper {
    justify-content: flex-start;
    gap: 8px;
}

#lower {
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- Utility Layouts ---------- */

.row {
    display: flex;
    flex-direction: row;
}

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

/* ---------- Header ---------- */

header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;

    width: 100%;
    gap: clamp(10px, 2vw, 20px);

    padding: clamp(8px, 1.5vh, 14px) clamp(14px, 2.5vw, 24px);

    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: clamp(14px, 2vh, 20px);

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

#renumera-icon {
    width: auto;
    height: clamp(24px, 5vh, 48px);
    object-fit: contain;

    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

header h1 {
    margin: 0;

    color: var(--primary);
    font-size: clamp(14px, 2.2vh, 24px);
    font-weight: 800;
    line-height: 1.1;

    text-align: left;
    white-space: normal;
    overflow-wrap: break-word;
}
/* ========================================
   STACKED LAYOUT: mascot > option box > dialogue > nav
   Keep this block last so it overrides the grid rules above.
   ======================================== */

#dialogue-container.start-up {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    bottom: auto;
}

#mascot {
    width: auto;
    height: clamp(120px, 26vh, 300px);
    max-width: 60vw;
    margin: 0;
    bottom: auto;
    position: relative;
}

/* Enlarged for the resume prompt. Higher specificity than #mascot in the media query. */
#mascot.start-up {
    width: min(60vw, 320px);
    height: auto;
    align-self: center;
}


/* ---------- Navigation ---------- */

#navigation-wrapper {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
}

#navigation-wrapper .action-btn {
    flex: 1;
    width: 100%;
}

.action-btn {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: clamp(6px, 1.2vh, 10px) clamp(12px, 2vw, 18px);

    background: var(--white);
    color: var(--primary);

    border: 2px solid var(--primary);
    border-radius: 12px;

    font-size: clamp(13px, 1.8vh, 15px);
    font-weight: 700;

    text-decoration: none;
    cursor: pointer;

    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--primary);
    color: var(--white);

    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(23, 59, 112, 0.2);
}

.next-btn,
.prev-btn {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 6px 14px rgba(23, 59, 112, 0.2);
}

.next-btn:hover,
.prev-btn:hover {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 6px 14px rgba(23, 59, 112, 0.2);
}

/* ---------- Dialogue Container ---------- */

#dialogue-container {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: flex-end;

    position: relative;
    z-index: 1;

    width: 100%;
    gap: clamp(12px, 2.5vw, 24px);

    overflow: visible;
    margin-bottom: 0;
    bottom: 0;
}

/* ---------- Mascot ---------- */

#mascot {
    width: auto;
    height: clamp(150px, 30vh, 380px);
    object-fit: contain;

    margin-bottom: -30px;
    bottom: -10px;

    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));

    transition: transform 0.3s ease;
}

/* ---------- Interaction Area ---------- */

#interaction-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;

    width: 100%;
    gap: 12px;
    z-index: 2;
}

#essay-box,
#choice-box {
    width: 100%;
    align-self: self-end;
}

/* ---------- Essay Container ---------- */

#essay-box {
    display: flex;
    flex-direction: column;
    gap: 8px;

    padding: clamp(10px, 1.6vh, 14px) clamp(12px, 2vw, 16px);

    background: var(--white);
    color: var(--primary);

    border: 2px solid var(--secondary);
    border-radius: 12px;

    font-size: clamp(12px, 1.7vh, 15px);
    font-weight: 600;
    text-align: left;

    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.1);
}

#essay-box label {
    display: block;
    margin-bottom: 0;

    font-size: clamp(12px, 1.6vh, 14px);
}

/* ---------- Essay Input and Button ---------- */

.input-action-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    /* Memastikan elemen di dalamnya bisa merata ke kanan */

    width: 100%;
    gap: 8px;
}

#essay-box input[type="text"] {
    flex: 1;
    width: 100%;

    padding: 8px 12px;

    border: 2px solid var(--primary);
    border-radius: 8px;

    font-family: inherit;
    font-size: clamp(12px, 1.7vh, 15px);
    color: var(--primary);

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

#essay-box input[type="text"]:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

/* ---------- Submit Essay ---------- */

#submit-essay {
    display: inline-flex;
    flex: 0 0 auto;
    /* Tidak memenuhi lebar, menyesuaikan isi */
    align-items: center;
    justify-content: center;

    padding: 8px 14px;
    margin-left: auto;
    /* Memaksa tombol geser ke ujung kanan */

    background: var(--primary);
    color: var(--white);

    border: 2px solid var(--primary);
    border-radius: 8px;

    font-size: clamp(11px, 1.5vh, 13px);
    font-weight: 700;

    text-decoration: none;
    cursor: pointer;

    transition: all 0.2s ease;
}

#submit-essay:hover {
    background: var(--secondary);
    border-color: var(--secondary);

    transform: translateY(-1px);
}

/* ---------- Choice Container ---------- */

.choice-container {
    display: flex;
    flex-direction: column;
    gap: 10px;

    width: 100%;

    padding: clamp(10px, 1.6vh, 14px) clamp(12px, 2vw, 16px);

    background: var(--white);

    border: 2px solid var(--secondary);
    border-radius: 12px;

    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.1);
}

/* ---------- Choice Buttons ---------- */

.choice-option-btn {
    display: block;
    width: 100%;

    padding: 10px 14px;

    background: var(--light-bg);
    color: var(--primary);

    border: 2px solid var(--border-color);
    border-radius: 8px;

    font-size: clamp(12px, 1.7vh, 15px);
    font-weight: 700;
    text-align: left;

    text-decoration: none;
    cursor: pointer;

    transition: all 0.2s ease;
}

.choice-option-btn:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);

    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(23, 59, 112, 0.15);
}

/* ---------- Dialogue Box ---------- */

#dialogue-box {
    display: flex;
    flex-direction: column;
    gap: 4px;

    position: relative;
    z-index: 2;

    width: 100%;
    min-width: 240px;
    min-height: 120px;

    padding: clamp(10px, 1.8vh, 16px) clamp(14px, 2.5vw, 20px);

    background: var(--white);
    border: 2.5px solid var(--primary);
    border-radius: 16px;

    box-shadow: 0 6px 16px rgba(23, 59, 112, 0.15);

    text-align: left;

    overflow-y: auto;

    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--scrollbar-bg);
}

/* ---------- Dialogue Scrollbar ---------- */

#dialogue-box::-webkit-scrollbar {
    width: 6px;
}

#dialogue-box::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 8px;
}

#dialogue-box::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
}

/* ---------- Speaker ---------- */

#speaker {
    margin: 0;

    color: var(--primary);
    font-size: clamp(16px, 1.7vh, 32px);
    font-weight: 800;
    letter-spacing: 0.8px;
}

/* ---------- Dialogue Text ---------- */

#dialogue {
    margin: 0;

    color: #2c3e50;
    font-size: clamp(13px, 1.9vh, 16px);
    font-weight: 600;
    line-height: 1.4;
}

#dialogue.typing::after {
    content: '▍';
    margin-left: 2px;
    animation: caret-blink 1s steps(2, start) infinite;
}

@keyframes caret-blink {
    to {
        visibility: hidden;
    }
}

/* Make the content wrapper expand and take up all available intermediate free space */
.content-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    flex: 1 1 auto;
    /* Allows it to expand and fill free space */
    width: 100%;
    height: 100%;
    min-height: 0;
    /* Prevents flex items from overflowing if content is large */
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE
   ======================================== */

@media (max-width: 768px) {

    /* ---------- Main Layout ---------- */

    main {
        min-height: 100vh;
        min-height: 100dvh;
        padding: 12px;
        gap: 12px;
    }

    /* ---------- Header ---------- */

    header {
        grid-template-columns: auto 1fr auto;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 14px;
    }

    #renumera-icon {
        height: clamp(28px, 6vw, 40px);
    }

    header h1 {
        font-size: clamp(14px, 3.5vw, 19px);
        text-align: left;
    }

    /* ---------- Navigation ---------- */

    #navigation-wrapper {
        gap: 8px;
    }

    .action-btn {
        gap: 5px;
        padding: 9px 8px;
        border-radius: 10px;
        font-size: 12px;
    }

    /* ---------- Dialogue Container ---------- */

    #dialogue-container {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 0;
        align-items: end;
    }

    /* ---------- Mascot ---------- */

    #mascot {
        width: auto;
        height: clamp(90px, 25vh, 150px);
        position: relative;
        margin-bottom: -10px;
        bottom: -30px;
        margin: -10px 10px 0;
    }

    /* ---------- Interaction Area ---------- */

    #interaction-row {
        gap: 10px;
    }

    #essay-box,
    #choice-box {
        width: 100%;
        align-self: stretch;
    }

    /* ---------- Essay Container ---------- */

    #essay-box {
        gap: 8px;
        padding: 12px;
        border-radius: 10px;
        font-size: 13px;
    }

    #essay-box label {
        font-size: 13px;
    }

    /* ---------- Essay Input ---------- */

    .input-action-wrapper {
        gap: 6px;
    }

    #essay-box input[type="text"] {
        min-width: 0;
        padding: 9px 10px;
        font-size: 13px;
    }

    #submit-essay {
        padding: 9px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* ---------- Choice Container ---------- */

    .choice-container {
        gap: 8px;
        padding: 8px;
        border-radius: 10px;
    }

    .choice-option-btn {
        padding: 6px 8px;
        font-size: 13px;
        border-radius: 8px;
    }

    /* ---------- Dialogue Box ---------- */

    #dialogue-box {
        width: 100%;
        min-width: 0;
        min-height: 100px;
        max-height: 125px;
        padding: 12px 14px;
        border-radius: 12px;
        border-width: 2px;
    }

    /* ---------- Speaker ---------- */

    #speaker {
        font-size: 17px;
        letter-spacing: 0.5px;
    }

    /* ---------- Dialogue Text ---------- */

    #dialogue {
        font-size: 13px;
        line-height: 1.5;
    }
}