/* Global variables */
:root {
    --primary-color: #1981c7;
    --secondary-color: #251605;
    --hover-color: #145a8a;
    --crossed_out-color: #888888;
    --missing-color: #ff4d4d;
    --font-family: 'Arial, sans-serif';
    --transition-duration: 0.3s;
    /* default navbar height -- can be overridden in media queries */
    --nav-height: 64px;
}

body {
    margin: 0;
    /* reset default browser margin */
    font-weight: 400;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    width: 100dvw;
    height: 100dvh;
    padding: 0;
    background-color: var(--secondary-color);
    text-align: center;

}

.burger {
    font-size: 24px;
    cursor: pointer;
    display: block;
}

.burger .line {
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 5px 0;
    transition: all var(--transition-duration);
}

/* Side menu (popup) */
.side_menu {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: 280px;
    max-width: 80%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), #fff);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    /* hidden by default (off-screen to the right) */
    transition: transform var(--transition-duration) ease;
    z-index: 1400;
    padding: 28px 16px;
    box-sizing: border-box;
}

.side_menu.open {
    transform: translateX(0);
    /* slide into view */
}

.side_menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

.side_menu li {
    margin: 12px 0;
}

.side_menu a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
}

/* backdrop when menu open */
.side_menu_backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-duration) ease;
    z-index: 1100;
}

.side_menu_backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

@media screen and (max-width: 768px) {
    .nav-links {
        display: none;
        /* Hide nav links by default on smaller screens */
        flex-direction: column;
        width: 100%;
    }

    .nav-links.active {
        display: flex;
        /* Show nav links when active */
    }

    /* Make the content window stack vertically on mobile, grow taller and scroll when needed. */
    .content_window {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        width: 100%;
        padding: 12px;
        box-sizing: border-box;
        min-height: 50dvh;
        max-height: 90dvh;
        overflow-y: auto;
    }

    /* thinner scrollbars on mobile where supported */
    .content_window::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    /* Ensure inner .window fills available width but remains centered and constrained */
    .window {
        width: 100%;
        max-width: 920px;
        margin: 0 auto;
        height: auto;
        box-sizing: border-box;
    }

    /* Make the results grid friendlier on small screens (narrower columns) */
    .results_window .results {
        /* keep the center column flexible (minmax(0,1fr)) so side columns
           can't force the center to shrink and make the third column grow */
        grid-template-columns: minmax(36px, 48px) minmax(0, 1fr) minmax(20px, 36px);
    }

    /* Increase tappable areas and readable text on mobile */
    nav {
        padding: 14px 16px;
        align-items: center;
        height: var(--nav-height, 64px);
    }

    .burger {
        font-size: 28px;
    }

    .burger .line {
        width: 30px;
        height: 4px;
        margin: 6px 0;
    }

    /* removed debug styles (background and oversized main font) */

    .results p {
        padding: 10px;
        font-size: 15px;
    }

    /* Slightly larger editor font on small screens */
    #rawData {
        font-size: 14px;
    }

}

/* remove default paragraph margin inside the nav */
nav p {
    margin: 0;
}

/* ensure nav spans full width and uses border-box sizing */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--primary-color);
    color: white;
    /* make navbar sticky so it remains above content and its height
       can be used to calculate available viewport space for content */
    position: sticky;
    top: 0;
    height: var(--nav-height);
    z-index: 1300;
}

.content_window {
    /* Layout container for app content. Use the navbar height to
       cap the maximum content area so it never gets hidden beneath
       the navbar (handles dynamic viewport units on mobile). */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    margin-top: 20px;
    box-sizing: border-box;
    padding: 0 20px;
    /* limit content window to viewport minus navbar; allow scrolling */
    max-height: calc(100dvh - var(--nav-height));
    overflow-y: auto;
}

/* .selection_window, */
.results_window,
.update_window,
.login_window {
    /* By default hidden */
    display: none;
}

.window {
    /* Child container inside content_window */
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 100%;
    max-width: 1200px;
    height: auto;
    /* ensure a single window does not overflow the available content area */
    max-height: calc(100dvh - var(--nav-height) - 48px);
    overflow: auto;
    box-sizing: border-box;
}

.date_buttons {
    /* Grid display of date buttons (7 buttons total) */
    /* Grid will be 2 columns and 4 rows. With first button spanning both rows */
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.date_buttons .date_button:first-child {
    grid-column: span 2;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color var(--transition-duration);
}

.date_button:hover {
    background-color: #145a8a;
    /* Darker shade on hover */
}

.results_window .results {
    /* create a 3-column grid: index | item (flex) | count
       Use minmax(0, 1fr) for the center column to prevent long
       inflexible content in the side columns from forcing the center
       column to shrink; this avoids the third column growing wider
       than the center on narrow screens. */
    display: grid;
    grid-template-columns: minmax(40px, 50px) minmax(0, 1fr) minmax(40px, 55px);
    gap: 8px;
    row-gap: 6px;
    align-items: start;
}

.results_window h2,
.results_window h3 {
    text-align: center;
    margin-top: 0;
}

.results-sort-heading {
    cursor: pointer;
    user-select: none;
    text-decoration: none;
}

.results-sort-heading.active {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.results-sort-heading:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    border-radius: 4px;
}

.results p {
    margin: 0;
    /* remove default paragraph margin */
    background-color: var(--primary-color);
    color: white;
    padding: 8px;
    /* slightly reduced padding */
    border-radius: 4px;
    line-height: 1.2;
    /* tighter line height */
}

.results p:hover {
    background-color: #145a8a;
    /* Darker shade on hover */
}

/* Prevent very long words or unbroken strings from widening grid columns */
.results p, .results h3 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Support rows rendered as wrapper <div> elements.
   Use display:contents where available so the children (h3/p)
   participate directly in the parent grid (preserves original layout).
   Provide a fallback for browsers without display:contents support. */
@supports (display: contents) {
    .results > div {
        display: contents;
    }
    /* Make result rows clickable and show checked state */
    .results > div.result-row {
        cursor: pointer;
    }
    .results > div.result-row.checked p {
        background-color: var(--crossed_out-color);
        color: black;
        text-decoration: line-through;
    }
    .results > div.result-row.missing p {
        background-color: var(--missing-color);
        color: white;
        text-decoration: none;
    }
}
@supports not (display: contents) {
    /* Fallback: make each row a three-column grid so visual layout remains similar. */
    .results {
        display: block;
    }
    .results > div {
        display: grid;
        grid-template-columns: minmax(40px, 50px) minmax(0, 1fr) minmax(40px, 55px);
        gap: 8px;
        margin-bottom: 6px;
        align-items: start;
    }
    .results > div h3, .results > div p {
        margin: 0;
    }
    /* Make result rows clickable and show checked state */
    .results > div.result-row {
        cursor: pointer;
    }
    .results > div.result-row.checked p {
        background-color: var(--crossed_out-color);
        color: black;
        text-decoration: line-through;
    }
    .results > div.result-row.missing p {
        background-color: var(--missing-color);
        color: white;
        text-decoration: none;
    }
}

/* Numbered editor inside update_window */
.editor_wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    height: 320px;
    margin-bottom: 12px;
    background: white;
}

.line_numbers {
    margin: 0;
    padding: 8px 10px;
    width: 48px;
    min-width: 38px;
    max-width: 80px;
    background: #f3f6fb;
    color: #666;
    text-align: right;
    line-height: 1.4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
    font-size: 13px;
    overflow: auto;
    user-select: none;
}

#rawData {
    flex: 1 1 auto;
    border: none;
    padding: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.4;
    resize: none;
    outline: none;
    overflow: auto;
}

/* Buttons below the editor */
.editor_buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 6px;
}

.editor_buttons .date_button {
    padding: 8px 12px;
    font-size: 14px;
}

/* ensure consistent thin scrollbars where supported */
.line_numbers,
#rawData {
    scrollbar-width: thin;
}