/* =========================================================================
   Emplacements palettes — feuille de style
   Direction : éditoriale + signalétique industrielle
   Papier crème, encre profonde, accent terre cuite
   ========================================================================= */

:root {
    /* Couleurs */
    --bg: #f4efe4;
    --bg-elev: #fbf7ec;
    --ink: #14110d;
    --ink-soft: #3d3830;
    --muted: #8a8276;
    --line: #d8d1c0;
    --line-soft: #e8e2d2;
    --accent: #b8472a;
    --accent-deep: #8e3621;
    --accent-soft: #f3d9ce;
    --pal: #2c5547;       /* vert sapin pour différencier les palettes */
    --pal-soft: #d3e1d9;
    --danger: #a8321c;
    --ok: #2c5547;

    /* Typo */
    --font-display: "Fraunces", "Iowan Old Style", "Hoefler Text", Georgia, serif;
    --font-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "Menlo", "Monaco", "Courier New", monospace;

    /* Layout */
    --container: 880px;
    --radius: 4px;
    --radius-lg: 8px;
    --shadow-hard: 4px 4px 0 0 var(--ink);
    --shadow-hard-sm: 2px 2px 0 0 var(--ink);
}

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

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Texture grain subtile en fond */
.bg-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

main, header, footer { position: relative; z-index: 1; }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }

/* ---- Header ----------------------------------------------------------- */
.site-header {
    max-width: var(--container);
    margin: 0 auto;
    padding: 24px 24px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
}

.brand-mark {
    font-size: 22px;
    line-height: 1;
    color: var(--ink);
    transform: translateY(-1px);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 0.95;
}

.brand-line1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.brand-line2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: 18px;
    color: var(--accent);
    letter-spacing: -0.01em;
}

.admin-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: var(--ink);
    color: var(--bg);
    padding: 5px 10px;
    border-radius: 2px;
}

.admin-link {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 2px;
}
.admin-link:hover { color: var(--bg); background: var(--ink); border-color: var(--ink); }

/* ---- Container -------------------------------------------------------- */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ---- Hero / page head ------------------------------------------------- */
.hero, .page-head {
    margin-bottom: 32px;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 12px;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    line-height: 1.02;
    letter-spacing: -0.025em;
    margin: 0 0 14px;
    color: var(--ink);
}

.hero-title em {
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
}

.hero-sub {
    color: var(--ink-soft);
    font-size: 16px;
    margin: 0 0 28px;
    max-width: 50ch;
}

.hero-sub code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--ink);
    color: var(--bg);
    padding: 2px 7px;
    border-radius: 2px;
    font-weight: 600;
}

.back-link {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 18px;
    transition: color 0.15s, transform 0.15s;
}
.back-link:hover {
    color: var(--accent);
    transform: translateX(-2px);
}

/* ---- Recherche -------------------------------------------------------- */
.search-wrap {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    font-family: var(--font-body);
    font-size: 22px;
    font-weight: 500;
    padding: 22px 60px 22px 24px;
    background: var(--bg-elev);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hard);
    outline: none;
    transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s;
}

.search-input::placeholder { color: var(--muted); font-weight: 400; }

.search-input:focus {
    border-color: var(--accent);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 var(--ink);
}

.spinner {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px; height: 22px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s;
}
.spinner.htmx-request { animation: spin 0.7s linear infinite; opacity: 1; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    color: var(--muted);
    font-size: 14px;
    font-family: var(--font-mono);
    margin-top: 18px;
}
.stat b { color: var(--ink); font-weight: 700; }
.stat-sep { color: var(--line); }

/* ---- Résultats -------------------------------------------------------- */
.results { margin-top: 24px; }

.results-meta {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 14px;
}
.results-meta b { color: var(--ink); }

.result-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    background: var(--bg-elev);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-hard-sm);
    transition: transform 0.12s, box-shadow 0.12s;
}
.result-card:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 0 var(--ink);
}

.result-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 19px;
    line-height: 1.25;
    margin-bottom: 14px;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: stretch;
    border: 1.5px solid var(--ink);
    border-radius: 4px;
    overflow: hidden;
    font-family: var(--font-mono);
    font-weight: 700;
    transition: transform 0.1s;
}
.tag:hover { transform: translateY(-1px); color: var(--ink); }

.tag-label {
    padding: 7px 10px;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--ink);
    color: var(--bg);
}

.tag-value {
    padding: 7px 12px;
    font-size: 16px;
    background: var(--bg-elev);
    color: var(--ink);
}

.tag-loc .tag-label { background: var(--accent); }
.tag-loc:hover .tag-value { background: var(--accent-soft); }

.tag-pal .tag-label { background: var(--pal); }
.tag-pal:hover .tag-value { background: var(--pal-soft); }

/* ---- Empty state ------------------------------------------------------ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}
.empty-mark {
    display: block;
    font-family: var(--font-display);
    font-size: 64px;
    line-height: 1;
    color: var(--line);
    margin-bottom: 16px;
}
.empty-state p { margin: 6px 0; }
.empty-state b { color: var(--ink); }
.empty-hint { font-size: 14px; color: var(--muted); }

/* ---- Footer ----------------------------------------------------------- */
.site-footer {
    max-width: var(--container);
    margin: 0 auto;
    padding: 24px;
    border-top: 1px solid var(--line);
    text-align: center;
}
.footer-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

/* =========================================================================
   ADMIN
   ========================================================================= */

.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    margin: 0 0 14px;
    letter-spacing: -0.01em;
}

.admin-form-wrap {
    background: var(--bg-elev);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-hard-sm);
}

.admin-form {
    display: grid;
    grid-template-columns: 1fr 130px 110px auto;
    gap: 12px;
    align-items: end;
}
.admin-form .field-grow { grid-column: 1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}
.field input,
.admin-search input,
.admin-row-edit input {
    font-family: var(--font-body);
    font-size: 15px;
    padding: 10px 12px;
    background: white;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}
.field input:focus,
.admin-search input:focus,
.admin-row-edit input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Boutons ---------------------------------------------------------- */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 16px;
    background: var(--bg-elev);
    color: var(--ink);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.08s, background 0.1s;
    box-shadow: var(--shadow-hard-sm);
    line-height: 1.2;
}
.btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 0 var(--ink);
    background: white;
}
.btn:active {
    transform: translate(1px, 1px);
    box-shadow: 0 0 0 0 var(--ink);
}

.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent-deep); color: var(--bg); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--bg-elev); border-color: var(--danger); }

.btn-sm { padding: 6px 10px; font-size: 12px; box-shadow: 1px 1px 0 0 var(--ink); }
.btn-sm:hover { box-shadow: 2px 2px 0 0 var(--ink); }

/* ---- Toolbar admin ---------------------------------------------------- */
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.admin-search {
    display: flex;
    gap: 8px;
    align-items: center;
}
.admin-search input { padding: 8px 12px; font-size: 14px; }
.link-muted { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.link-muted:hover { color: var(--accent); }

/* ---- Table admin ------------------------------------------------------ */
.admin-table {
    background: var(--bg-elev);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-hard-sm);
}

.admin-table-head,
.admin-row,
.admin-row-edit {
    display: grid;
    grid-template-columns: 60px 1fr 130px 100px 160px;
    gap: 12px;
    padding: 12px 16px;
    align-items: center;
    border-bottom: 1px solid var(--line-soft);
}

.admin-table-head {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 1.5px solid var(--ink);
}

.admin-row { font-size: 14px; transition: background 0.1s; }
.admin-row:hover { background: var(--bg); }
.admin-row:last-child { border-bottom: none; }

.admin-row-edit { background: var(--accent-soft); }

.col-id { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 600; }
.col-title { font-family: var(--font-display); font-weight: 500; line-height: 1.3; }
.col-act { display: flex; gap: 6px; justify-content: flex-end; }

.mono-tag {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    background: white;
    border: 1px solid var(--line);
    padding: 3px 8px;
    border-radius: 3px;
}

/* =========================================================================
   RESPONSIVE — mobile first (préparateurs sur téléphone)
   ========================================================================= */
@media (max-width: 720px) {
    body { font-size: 16px; }
    .container { padding: 20px 16px 60px; }
    .site-header { padding: 16px; }

    .search-input {
        font-size: 18px;
        padding: 18px 50px 18px 18px;
    }

    .result-card { padding: 16px; }
    .result-title { font-size: 17px; }
    .tag-value { font-size: 15px; }

    /* Empile le formulaire admin verticalement */
    .admin-form { grid-template-columns: 1fr; }
    .admin-form .field-grow { grid-column: 1; }

    /* Cartes admin au lieu de la grille */
    .admin-table-head { display: none; }
    .admin-row, .admin-row-edit {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px;
    }
    .admin-row > span:not(.col-act),
    .admin-row-edit > span:not(.col-act) {
        display: flex; align-items: center; gap: 8px;
    }
    .admin-row > span:not(.col-act)::before {
        font-family: var(--font-mono);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--muted);
        min-width: 70px;
    }
    .admin-row .col-id::before { content: "ID"; }
    .admin-row .col-title::before { content: "Titre"; }
    .admin-row .col-loc::before { content: "Empl."; }
    .admin-row .col-pal::before { content: "Palette"; }
    .col-act { justify-content: flex-start; }
}

/* HTMX : transition douce des fragments */
.htmx-swapping { opacity: 0; transition: opacity 0.1s; }
.htmx-settling { opacity: 1; transition: opacity 0.15s; }
