:root {
    --header-height: 60px; /* Define once to use everywhere */
    --plate-height: 60px;
}

/* (Re)set some more useful defaults */
body {
    font-family: sans-serif;
}
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Remove default margin */
*:not(dialog) {
    margin: 0;
}

button {
    cursor: pointer;
}

.navbar {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: #bbb;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 0 0;
    z-index: 1000;
    box-sizing: border-box;
}

/* Hamburger menu */
.menu-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Base style for all three lines */
.menu-toggle span {
    display: block;
    position: absolute;
    height: 4px;
    width: 100%;
    background-color: #444;
    border-radius: 2px;
    opacity: 1;
    left: 0;

    /* Transform form exact center */
    transform-origin: center center;
    transition: 0.25s ease-in-out;
}

/* 3 horizontal lines ("hamburger"), evenly spaced. */
.menu-toggle span:nth-child(1) {
    top: 10px;
}
.menu-toggle span:nth-child(2) {
    top: 18px;
}
.menu-toggle span:nth-child(3) {
    top: 26px;
}

/* Animation to "X" state */
/* Middle line fades away */
.menu-toggle.open span:nth-child(2) {
    width: 0%;
    opacity: 0;
}

/* 2. Top and Bottom lines move to the middle (top: 18px) and rotate */
.menu-toggle.open span:nth-child(1) {
    top: 18px; /* Move to the center vertical position */
    transform: rotate(45deg);
}
.menu-toggle.open span:nth-child(3) {
    top: 18px; /* Move to the center vertical position */
    transform: rotate(-45deg);
}

/* Navigation / menu */
.nav-links {
    position: absolute;
    top: var(--header-height);
    left: 0;
    background: #ccc;
    width: 100%;
    display: none; /* Hidden by default */
    flex-direction: column;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.nav-links.active {
    display: flex;
}

.nav-links :is(a, button) {
    color: #333;
    padding: 15px;
    text-decoration: none;
    border-bottom: 1px solid #555;
    /*font-family: sans-serif;*/

    display: inline-block; /* Ensures padding/margins behave the same */
    background: none; /* Removes default grey button color */
    border-top: none; /* Removes default 3D button borders */
    border-left: none;
    border-right: none;
    cursor: pointer; /* Gives the button the 'link' hand icon */
    font-size: inherit; /* Buttons often default to smaller text */
    line-height: normal; /* Matches text flow */
}

.nav-links :is(a, button):hover {
    background: #555;
    color: #fff;
}

/* Main grid */
.grid-container {
    display: flex;
    flex-wrap: wrap;
    /* Kaap some room for the "add" button at the bottom */
    padding: 10px 10px 100px 10px;
    width: 100%;
    margin: 0 auto;
}

.grid-item {
    display: grid;
    grid-template-columns: auto min-content;

    background: #f4f4f4;
    padding: 5px;
    margin: 3px;

    transition: width 0.3s ease-in-out;
    animation: expand 0.3s forwards;
    overflow: hidden;
}
.grid-item object {
    display: block;
    width: 100%;

    grid-column: 1;
    grid-row: 1;
}
.grid-item .plate-label {
    grid-column: 2;
    grid-row: 1;
    writing-mode: vertical-rl;
    white-space: nowrap;
    padding: 3px 0;
    font-size: 0.8rem;
}
.grid-item .timestamp {
    grid-column: 1 / span 2;
    grid-row: 2;
    text-align: center;
    padding-top: 3px;
    font-size: 0.6rem;
}

/* "I saw a thing!" button */
.add-btn {
    position: fixed;
    bottom: 30px;
    left: 50%;
    height: 60px;
    transform: translateX(-50%); /* Perfectly centers the button */
    padding: 15px 40px;
    font-size: 1.2rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
    white-space: nowrap;
}

/* "I saw a thing!" button */
.stats-btn {
    position: fixed;
    bottom: 45px;
    right: 30px;

    height: 30px;
    width: 30px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background-color: #7b7b7b;
    color: white;
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

/* The license-plate-y header */
.license-plate {
    /* Use flex to ensure children can fill the height */
    display: inline-flex;
    align-items: stretch; /* Forces children to be the same height */
    height: var(--plate-height);
}

dialog:open {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: var(--plate-height);
    border-radius: 8px;
    width: 65%;
    text-align: center; /* Ensures text itself is centered */
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(1px);
}

dialog h2 {
    margin: 10px 0;
    text-align: center; /* Ensures text itself is centered */
    font-size: 1.2rem;
}
dialog p,
dialog table {
    margin: 0 0 1.5rem;
}

#stats-modal {
    width: 90%;
}
#stats-modal table th {
    text-align: right;
    font-weight: normal;
}

#add-plate-modal form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#add-plate-label {
    font-size: 0.8rem;
}

#add-plate-new-code {
    text-align: center;

    /* Make the code entry field nice and big */
    font-size: 1.5rem;
    margin-top: 0.75rem;
}

#new-code {
    text-transform: uppercase;
}

#close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
}

#close-button:hover {
    color: red;
}

#add-plate-error {
    width: 100%;
    padding: 0;

    font-size: 80%;
    color: white;
    background-color: #990000;
    border-radius: 5px 5px;

    box-sizing: border-box;
}

#add-plate-error.active {
    padding: 0.3em;
}

#about-modal:open {
    width: 90%;
}
#about-modal p {
    text-align: left;
}

@keyframes expand {
    from {
        width: 0;
        opacity: 0;
        margin-right: -8px; /* Offset the gap during animation */
    }
    to {
        width: 85px;
        opacity: 1;
        margin-right: 0;
    }
}
