@font-face {
    font-family: "Imperial Script";
    src: url("/static/fonts/ImperialScript-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Crimson Text";
    src: url("/static/fonts/CrimsonText-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Crimson Text";
    src: url("/static/fonts/CrimsonText-Italic.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

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

button, input, select, textarea {
    font-family: inherit;
}

:root {
    --bg: #faf9f7;
    --card-bg: #ffffff;
    --text: #2d2d2d;
    --text-muted: #6b6b6b;
    --accent: #7c9885;
    --accent-hover: #6a8673;
    --border: #e5e2de;
    --claimed-bg: #f5f3f0;
    --success: #7c9885;
    --error: #c45d4e;
    --radius: 8px;
}

body {
    font-family: "Crimson Text", Georgia, serif;
    background: #000;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)), url("/static/bg-web.jpg") center/cover no-repeat;
}

header {
    text-align: center;
    padding: 10vh 1rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 4px 16px rgba(0, 0, 0, 0.8);
}

header h1 {
    font-family: "Imperial Script", cursive;
    font-size: 5rem;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.1;
}

.subtitle {
    font-family: "Crimson Text", Georgia, serif;
    margin-top: 0.5rem;
    font-size: 1.1rem;
    opacity: 0.95;
}

@media (max-width: 600px) {
    header {
        padding-top: 5vh;
    }

    header h1 {
        font-size: 3rem;
    }
}

@media (min-width: 600px) {
    .subtitle {
        font-size: 1.3rem;
    }
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
    width: 100%;
    flex: 1;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
    opacity: 0.85;
    font-size: 0.85rem;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #eef5f0;
    color: #2d5a3d;
}

.flash-error {
    background: #fdf0ee;
    color: #8b3325;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: #fff;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
    font-size: 1.1rem;
}

/* Categories */
.category {
    margin-bottom: 2rem;
}

.category h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.sort-bar {
    margin-bottom: 1rem;
    text-align: right;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
    font-size: 0.9rem;
}

.sort-bar select {
    margin-left: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    font: inherit;
}

/* Items grid */
.items-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Item card */
.item-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
}

.item-card.claimed {
    background: #d8d5d0;
    color: var(--text-muted);
}

.item-card.claimed .item-image img {
    filter: grayscale(0.7);
}

.item-image {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg);
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-details {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-details .claim-form,
.item-details .fully-claimed-badge {
    margin-top: auto;
}

.item-details h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.item-details h3 a {
    color: var(--accent);
    text-decoration: none;
}

.item-details h3 a:hover {
    text-decoration: underline;
}

.item-link {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.5rem;
}

.item-link:hover {
    text-decoration: underline;
}

.claim-confirm {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.claim-confirm[hidden] {
    display: none;
}

.claim-qty {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 4rem;
}

.item-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.item-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.price {
    font-weight: 600;
}

.quantity {
    color: var(--text-muted);
}

/* Claims */
.claims-list {
    margin-bottom: 0.75rem;
}

.claim-entry {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.25rem 0;
    flex-wrap: wrap;
}

.claimed-by {
    color: var(--accent);
    font-weight: 500;
}

.claim-note {
    color: var(--text-muted);
}

.unclaim-form {
    display: inline;
}

.btn-unclaim {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.btn-unclaim:hover {
    background: var(--error);
    color: white;
}

/* Claim button & form */
.btn-claim {
    display: block;
    width: 100%;
    padding: 0.6rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-claim:hover {
    background: var(--accent-hover);
}

.claim-form {
    flex-direction: column;
    gap: 0.5rem;
}

.claim-form:not([hidden]) {
    display: flex;
}

.claim-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.claim-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

.quantity-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.quantity-label select {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.claim-form-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-confirm {
    flex: 1;
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-confirm:hover {
    background: var(--accent-hover);
}

.btn-cancel {
    padding: 0.5rem 1rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-cancel:hover {
    background: var(--bg);
}

.fully-claimed-badge {
    text-align: center;
    padding: 0.5rem;
    color: var(--accent);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Admin */
.admin-login {
    max-width: 320px;
    margin: 3rem auto;
    text-align: center;
}

.admin-login h2 {
    margin-bottom: 1rem;
}

.admin-login form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-login input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-nav {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.admin-nav a {
    color: var(--accent);
    text-decoration: none;
}

.admin-nav a:hover {
    text-decoration: underline;
}

.admin-section {
    margin-bottom: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.admin-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.item-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-row label {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-row input,
.form-row select {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
}

.form-row input:focus,
.form-row select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-actions .btn-cancel {
    text-decoration: none;
    text-align: center;
}

.btn-edit {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-edit:hover {
    text-decoration: underline;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-delete:hover {
    text-decoration: underline;
}

.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .admin-table {
        font-size: 0.8rem;
    }
    .admin-table th,
    .admin-table td {
        padding: 0.4rem;
    }
}

.image-zone {
    flex: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg);
    transition: border-color 0.15s, background 0.15s;
}

.image-zone.dragging {
    border-color: var(--accent);
    background: var(--card-bg);
}

.image-zone-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.image-zone input[type="file"] {
    font-size: 0.9rem;
}

.image-zone img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius);
    object-fit: contain;
    margin-top: 0.5rem;
}
