@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;700&family=Source+Sans+3:wght@400;600&display=swap');

/* Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    font-family: 'Source Sans 3', sans-serif;
    height: 100%;
    overflow: hidden;
}

button {
    padding: 5px;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-right: 10px;
}

.hidden {
    display: none !important;
}

/* Shared branding, backdrops, and panels */
#strip-leaf,
#drawer-leaf {
    width: 38px;
    height: 54px;
    flex-shrink: 0;
}

#strip-title,
#drawer-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 24px;
    color: #243830;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
    display: flex;
    gap: 0.25em;
}

#strip-title .dot,
#drawer-title .dot {
    color: #97c459;
}

#close-btn,
#popup-close-btn,
#feedback-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #c5d9ce;
    line-height: 1;
    padding: 4px;
    margin: 0;
}

#close-btn:hover,
#popup-close-btn:hover,
#feedback-close-btn:hover {
    color: #5cad7a;
}

#drawer-backdrop,
#popup-backdrop,
#feedback-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
}

#drawer-backdrop {
    z-index: 999;
}

#popup-backdrop,
#feedback-backdrop {
    z-index: 1100;
}

#drawer-backdrop.open,
#popup-backdrop.open,
#feedback-backdrop.open {
    display: block;
}

#popup-panel,
#feedback-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    max-height: 85vh;
    background: rgba(248, 250, 248, 1);
    border: 1px solid #1a2b24;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    z-index: 1101;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

#popup-panel.open,
#feedback-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

#popup-header,
#feedback-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    flex-shrink: 0;
}

/* Map, analysis status, and zoom controls */
#map-container {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

.map_cl {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -25px;
    bottom: -25px;
}

#progress-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    pointer-events: none;
}

.progress-bar {
    width: 100%;
    height: 3px;
    background-color: transparent;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: #ce1313;
    width: 0%;
    display: none;
    transition: width 0.3s ease-in-out, opacity 0.4s ease;
}

#analysis-status {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    max-width: min(600px, calc(100vw - 24px));
    padding: 12px 18px;
    background: #f8faf8;
    color: #243830;
    border: 1px solid #c5d9ce;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    z-index: 1200;
    font-size: 14px;
}

#analysis-status.error {
    color: #b3261e;
    border-color: #b3261e;
}

#analysis-status[hidden] {
    display: none;
}

#analysis-status-close {
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

#zoom-controls {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: none;
    flex-direction: column;
    background: rgba(248, 250, 248, 1);
    border: 1px solid #1a2b24;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    z-index: 900;
}

.zoom-btn {
    width: 52px;
    height: 52px;
    border: none;
    background: #f4f8f5;
    color: #243830;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation; /* Allow pinch; avoid page zoom on repeated +/- taps. */
    transition: background 0.15s ease;
}

.zoom-btn:hover {
    background: #e6f0ea;
}

.zoom-btn:active {
    background: #243830;
    color: #ffffff;
}

#zoom-in-btn {
    border-bottom: 1px solid #c5d9ce;
}

/* Collapsed sidebar */
#sidebar-strip {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 280px;
    background: rgba(248, 250, 248, 1);
    border: 1px solid #1a2b24;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    padding: 18px 20px 16px;
    gap: 12px;
    z-index: 900;
    transition: opacity 0.25s ease;
}

#sidebar-strip.hidden {
    opacity: 0;
    pointer-events: none;
}

#strip-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#strip-brand-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#strip-desc {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12.5px;
    color: #5c6863;
    line-height: 1.55;
    margin: 0;
}

#hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
    margin: 0;
    flex-shrink: 0;
}

#hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: #243830;
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

#hamburger-btn:hover span {
    background-color: #5cad7a;
}

#strip-draw-controls {
    display: flex;
    gap: 8px;
}

.strip-mode-btn {
    flex: 1;
    height: 36px;
    border: 1px solid #c5d9ce;
    border-radius: 8px;
    background: #f4f8f5;
    color: #425052;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    padding: 0;
    margin: 0;
}

.strip-mode-btn:hover {
    background: #e6f0ea;
}

.strip-mode-btn-active {
    background: #243830;
    color: #ffffff;
    border-color: #243830;
}

/* Navigation drawer and index options */
#sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100%;
    background-color: #ffffff;
    border-right: 1px solid #d0d8d9;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

#sidebar-drawer.open {
    transform: translateX(0);
}

#drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffffff;
    padding: 22px 20px 20px;
    flex-shrink: 0;
}

#drawer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

#drawer-about,
#drawer-options {
    padding: 20px 20px 0;
}

.drawer-section-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.1em;
    line-height: 1.6;
    text-transform: uppercase;
    color: #425052;
    margin-bottom: 8px;
}

.line {
    border: none;
    border-top: 2px solid rgb(39, 80, 10);
    width: calc(100% - 40px);
    margin: 20px 20px 0;
    opacity: 0.55;
}

#drawer-about p {
    font-size: 14px;
    color: #425052;
    line-height: 1.6;
}

#drawer-about a {
    color: #425052;
    font-weight: 600;
    text-decoration: underline;
}

#drawer-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#drawer-options .option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #425052;
}

#drawer-options input[aria-invalid="true"] {
    border-color: #b3261e;
}

#drawer-options input[type="number"] {
    width: 70px;
    padding: 4px 6px;
    border: 1px solid #d0d8d9;
    border-radius: 6px;
    font-size: 13px;
    color: #425052;
    text-align: right;
    outline: none;
    -moz-appearance: textfield;
}

#drawer-options input[type="number"]:focus {
    border-color: #97A7A8;
}

#drawer-options input[type="number"]::-webkit-inner-spin-button,
#drawer-options input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Polygon result popup */
#popup-panel {
    width: min(720px, 95vw);
}

#popup-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#popup-gyf-score {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 42px;
    color: #243830;
    line-height: 1;
}

#popup-body {
    overflow-y: auto;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#popup-body .line {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.popup-section {
    padding: 16px 0 0;
}

.popup-section canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin-top: 8px;
}

#popup-hist-canvas {
    border-radius: 0;
}

#popup-images {
    display: flex;
    gap: 12px;
}

#popup-images .popup-section {
    flex: 1;
    min-width: 0;
}

#desktop-toggle-container {
    display: flex;
    justify-content: flex-start;
    margin-top: 12px;
}

#desktop-toggle-container button {
    flex: none;
    width: auto;
    padding: 0 16px;
}

/* Feedback */
#open-feedback-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    width: auto;
    height: 42px;
    padding: 0 18px;
    margin: 0;
    background: rgba(248, 250, 248, 1);
    border: 1px solid #1a2b24;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    z-index: 900;
}

#open-feedback-btn:hover {
    background: #e6f0ea;
    border-color: #97c459;
}

#feedback-panel {
    width: min(480px, 92vw);
}

#feedback-form {
    overflow-y: auto;
    padding: 4px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feedback-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feedback-field > label:first-child {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    color: #243830;
}

#feedback-stars {
    display: flex;
    gap: 6px;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    padding: 0;
    margin: 0;
    color: #d0d8d9;
    transition: color 0.1s ease, transform 0.1s ease;
}

.star-btn:hover {
    transform: scale(1.1);
}

.star-btn.filled {
    color: #97c459;
}

.feedback-radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}

.feedback-radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #425052;
    cursor: pointer;
}

.feedback-radio-group input[type="radio"] {
    accent-color: #243830;
    cursor: pointer;
}

#feedback-comments,
#feedback-email {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13.5px;
    color: #425052;
    border: 1px solid #d0d8d9;
    border-radius: 8px;
    outline: none;
}

#feedback-comments {
    padding: 10px;
    resize: vertical;
}

#feedback-email {
    padding: 8px 10px;
}

#feedback-comments:focus,
#feedback-email:focus {
    border-color: #97A7A8;
}

.feedback-checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: #243830;
    cursor: pointer;
}

.feedback-checkbox-row input[type="checkbox"] {
    accent-color: #243830;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.feedback-status {
    font-size: 13px;
    min-height: 18px;
}

.feedback-status.error {
    color: #b3261e;
}

.feedback-status.success {
    color: #2e7d32;
}

.feedback-submit-btn {
    height: 42px;
    border: none;
    border-radius: 10px;
    background: #243830;
    color: #ffffff;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.feedback-submit-btn:hover {
    background: #1a2b24;
}

.feedback-submit-btn:disabled {
    background: #97A7A8;
    cursor: not-allowed;
}

/* Responsive layouts */
@media (max-width: 600px) {
    .feedback-radio-group {
        grid-template-columns: 1fr;
    }

    #strip-title {
        font-size: 28px;
    }

    #popup-images {
        flex-direction: column;
    }

    #popup-img-toggle {
        display: flex;
        margin-top: 16px;
    }

    #sidebar-strip {
        top: 12px;
        left: 12px;
        right: 12px;
        width: auto;
        padding: 10px 14px;
        gap: 8px;
    }

    #strip-desc {
        display: none;
    }

    #strip-leaf {
        width: 28px;
        height: 40px;
    }

    #hamburger-btn {
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }

    #strip-draw-controls .strip-mode-btn {
        height: 44px;
    }

    #desktop-toggle-container {
        display: none !important;
    }

    #open-feedback-btn {
        top: auto;
        bottom: 28px;
        right: 12px;
    }
}

@media (min-width: 601px) {
    #popup-img-toggle {
        display: none !important;
    }

    #popup-header {
        cursor: grab;
        touch-action: none; /* Keep pointer events for dragging the result panel. */
    }

    #popup-header:active {
        cursor: grabbing;
    }
}

/* The lab shortcut selects kiosk mode with ?kiosk=1, at any screen resolution. */
html.kiosk #zoom-controls {
    display: flex;
}

html.kiosk #open-feedback-btn {
    display: none;
}

/* Retain the compact mobile layout when previewing kiosk mode on a small screen. */
@media (min-width: 601px) {
    html.kiosk #sidebar-strip {
        top: 28px;
        left: 28px;
        width: 520px;
        padding: 34px 38px 30px;
        gap: 22px;
        border-radius: 26px;
    }

    html.kiosk #strip-leaf {
        width: 70px;
        height: 100px;
    }

    html.kiosk #strip-title {
        font-size: 44px;
    }

    html.kiosk #strip-desc {
        font-size: 22px;
        line-height: 1.6;
    }

    html.kiosk #hamburger-btn span {
        width: 30px;
        height: 3px;
    }

    html.kiosk #strip-draw-controls {
        gap: 16px;
    }

    html.kiosk .strip-mode-btn {
        height: 64px;
        font-size: 24px;
        border-radius: 14px;
    }

    html.kiosk #zoom-controls {
        right: 40px;
        bottom: 40px;
        border-radius: 26px;
    }

    html.kiosk .zoom-btn {
        width: 96px;
        height: 96px;
        font-size: 48px;
    }
}
