* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; color: #222; background: #fafafa; }

/* Sticky stack: header, then page title, then search bar.
   Explicit heights so each one knows where the one above it ends. */
:root {
    --header-h: 5rem;
    --title-h: 3.25rem;

    /* Brand palette, sampled from the ToolCheck header artwork: the bar's
       gradient, the pale blue of "Check", and the amber of the check badge
       and ".gr". Everything below is drawn from these. */
    --brand-blue: #2563eb;
    --brand-blue-deep: #1e3a8a;
    --brand-blue-hover: #1d4ed8;
    --brand-blue-tint: #bfdbfe;
    --brand-amber: #f59e0b;
    /* Amber dark enough to stay readable as text on white (#f59e0b is not) */
    --brand-amber-text: #b45309;
    --brand-gradient: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-deep));
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
    --hairline: #e2e5ea;
    --text-muted: #6b7280;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-h);
    display: flex;
    align-items: center;
    /* Matches the gradient baked into the ToolCheck header artwork, so the bar
       continues seamlessly past the logo at any viewport width. The served SVG
       is assets/brand/toolcheck-header.svg with its background rect stripped;
       regenerate it with assets/brand/make-web-header.sh. */
    background: var(--brand-gradient);
    padding: 0 1.5rem;
}
.site-brand { display: flex; align-items: center; height: 100%; }
.site-brand img { height: 100%; width: auto; display: block; }

@media (max-width: 480px) {
    :root { --header-h: 3.75rem; }
    .site-header { padding: 0 0.75rem; }
}

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

h1 { font-size: 1.5rem; }

/* Scoped to the Home page: ProductDetail's h1 is the product name and must not stick */
.page-title {
    position: sticky;
    top: var(--header-h);
    z-index: 15;
    display: flex;
    align-items: center;
    height: var(--title-h);
    margin: 0;
    color: var(--brand-blue-deep);
    background: #fafafa;
}

.result-count { color: #666; margin-bottom: 1rem; }
.no-results { color: #666; padding: 2rem 0; }

.search-bar {
    position: sticky;
    top: calc(var(--header-h) + var(--title-h));
    z-index: 10;
    /* Opaque, matching body, so cards scroll out of sight behind it */
    background: #fafafa;
    padding: 0.75rem 0 1rem;
}

/* Search and page size are one control rail rather than two floating boxes,
   so the rail's right edge is also the product grid's right edge. */
.search-rail {
    position: relative;
    display: flex;
    align-items: stretch;
    background: #fff;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    /* Keeps the index mark inside the rounded corners */
    overflow: hidden;
    transition: border-color 0.15s ease;
}
.search-rail:focus-within { border-color: var(--brand-blue); }

/* The index mark on a caliper: an amber line slides out from the left when
   the field takes focus. :has is the enhancement — the border above is what
   guarantees a visible focus state everywhere. */
.search-rail::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: var(--brand-amber);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease-out;
}
.search-rail:has(.search-input:focus)::after { transform: scaleX(1); }

.search-field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.9rem;
}
.search-icon {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--brand-blue-deep);
}
.search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.8rem 0;
    font: inherit;
    font-size: 1rem;
    color: #222;
    background: none;
    border: 0;
    outline: none;
}
.search-input::placeholder { color: #9aa1ab; }
/* Suppressed so it doesn't sit next to our own clear button */
.search-input::-webkit-search-cancel-button { appearance: none; }

.search-clear {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    color: var(--text-muted);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}
.search-clear svg { width: 15px; height: 15px; }
.search-clear:hover { color: #222; background: #f1f3f6; }
.search-clear:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: 1px;
}

.page-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.9rem;
    border-left: 1px solid var(--hairline);
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.page-size select {
    /* Chevron drawn here so the control matches the rail rather than the OS */
    appearance: none;
    padding: 0.8rem 1.5rem 0.8rem 0.25rem;
    font: inherit;
    font-size: 0.95rem;
    color: #222;
    background: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.35rem center;
    background-size: 12px;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}
.page-size select:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: -1px;
}

@media (max-width: 560px) {
    /* The select keeps its name through aria-label once this is hidden */
    .page-size-label { display: none; }
    .search-field { padding: 0 0.7rem; }
    .page-size { padding: 0 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .search-rail,
    .search-rail::after { transition: none; }
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 3rem 0 2rem;
}
.page-btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--brand-blue);
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.1s ease, background 0.1s ease;
}
.page-btn:hover:not(:disabled) { border-color: var(--brand-blue); }
.page-btn:disabled { color: #aaa; cursor: default; }
.page-btn.active {
    color: #fff;
    background: var(--brand-blue);
    border-color: var(--brand-blue);
    font-weight: 600;
}
.page-ellipsis { color: #888; font-size: 1rem; padding: 0 0.25rem; }

.availability-section { margin-bottom: 3rem; }
.availability-header {
    display: inline-block;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: var(--brand-gradient);
    padding: 0.35rem 0.85rem;
    border-radius: 4px;
    margin: 0 0 1rem;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease;
}
.product-card:hover {
    border-color: var(--brand-blue-tint);
    box-shadow: 0 2px 10px rgba(30, 58, 138, 0.12);
}
.product-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #fff; padding: 0.5rem; }
.product-card-body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.product-brand { font-size: 0.75rem; text-transform: uppercase; color: #888; }
.product-title { font-size: 0.95rem; margin: 0; line-height: 1.3; }
.product-price { font-weight: 700; color: var(--brand-amber-text); }

.back-link { display: inline-block; margin-bottom: 1rem; color: var(--brand-blue); text-decoration: none; }

.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; background: #fff; padding: 1.5rem; border-radius: 8px; }
.product-detail-main-image { width: 100%; object-fit: contain; }
.product-detail-thumbnails { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.product-detail-thumbnails img { width: 64px; height: 64px; object-fit: contain; border: 1px solid #e0e0e0; border-radius: 4px; cursor: pointer; transition: border-color 0.1s ease; }
.product-detail-thumbnails img:hover,
.product-detail-thumbnails img.active { border-color: var(--brand-blue); }
.product-detail-price { font-size: 1.5rem; font-weight: 700; color: var(--brand-amber-text); }
.product-erp { color: #888; font-size: 0.85rem; }
.product-lidl-link {
    display: inline-block;
    align-self: flex-start;
    margin: 0.5rem 0 1rem;
    padding: 0.7rem 1.2rem;
    color: #fff;
    background: var(--brand-blue);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.1s ease;
    /* Anchors and clips the click ripple spawned by spawnRipple() */
    position: relative;
    overflow: hidden;
}
.product-lidl-link:hover { background: var(--brand-blue-hover); }
.product-lidl-link .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    pointer-events: none;
    animation: ripple 0.5s ease-out forwards;
}

@keyframes ripple {
    to { transform: scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .product-lidl-link .ripple { animation: none; display: none; }
}

.product-description ul { padding-left: 1.2rem; }
.product-description li { margin-bottom: 0.35rem; }

@media (max-width: 700px) {
    .product-detail { grid-template-columns: 1fr; }
}

/* Version footer. Deliberately quiet: it is provenance information, not
   content, so it sits below the fold of interest in muted small type. */
.site-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--hairline);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: right;
}
