/* ---------------------------------------------------------------------------
   Rolou Barato

   The page has exactly one job: let someone scan down a column of R$/kg and
   find the cheap row. The chrome stays out of the way of that, but it's
   allowed a little personality -- rounder shapes, and colour drawn from the
   real filament palette (see the wordmark thread) rather than pure monochrome.
   The R$/kg figure is still the one loud element; now it's a loud colour too.
   ------------------------------------------------------------------------- */

:root {
  --paper:   #E8E9E4;
  --surface: #F7F7F4;
  --ink:     #1E2422;
  --muted:   #66706B;
  --rule:    #CBCDC5;
  --accent:  #2E5E4E;
  --accent2: #C9862E;
  --alert:   #A6432B;

  --space:  1rem;
  --radius: 12px;
}

[data-theme="dark"] {
  /* Pure black/grey, no warm or green tint -- colour is reserved entirely
     for the accents and the real filament swatches. */
  --paper:   #0A0A0B;
  --surface: #141416;
  --ink:     #F2F2F1;
  --muted:   #8C8C90;
  --rule:    #242427;
  --accent:  #6FB89A;
  --accent2: #F0B84D;
  --alert:   #E0805F;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--space);
  top: var(--space);
  background: var(--surface);
  padding: .5rem .75rem;
  z-index: 10;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- masthead ----------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.masthead-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem var(--space) 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: .5rem 1.25rem;
}

.wordmark {
  font-family: "Space Grotesk", Archivo, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}

/* a short length of filament, spooling off the left of the wordmark -- in the
   actual colours the listings come in, not a generic accent gradient */
.wordmark-thread {
  display: block;
  width: 30px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, #C0392B, #F2C10E, #2E8B4F, #1F6FB2, #6B3FA0);
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: .875rem;
}

.masthead-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .875rem;
}

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

.switch {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.switch a {
  padding: .15rem .5rem;
  color: var(--muted);
  font-weight: 500;
}
.switch a[aria-current] {
  background: var(--accent);
  color: var(--surface);
}

.theme-toggle { font-size: 1.1rem; line-height: 1; }

/* --- cheapest-today ticker ---------------------------------------------- */

.ticker {
  max-width: 1120px;
  margin: 0 auto;
  padding: .875rem var(--space);
  display: flex;
  gap: 1.75rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--rule);
  scrollbar-width: thin;
}

.ticker-item {
  flex: 0 0 auto;
  text-decoration: none;
  display: grid;
  gap: .05rem;
}

.ticker-material {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.ticker-low {
  font-family: "Space Grotesk", Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}

.ticker-median {
  font-size: .75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- layout -------------------------------------------------------------- */

.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem var(--space) 3rem;
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 2.25rem;
  align-items: start;
}

/* --- filters ------------------------------------------------------------- */

.filters {
  display: grid;
  gap: 1.125rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding-right: .25rem;
}

.filters .field { display: grid; gap: .35rem; }

.filters label,
.filters legend {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
}

.filters fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.checks {
  display: grid;
  gap: .2rem;
  max-height: 11rem;
  overflow-y: auto;
}

.checks label,
.toggles label {
  font-weight: 400;
  color: var(--ink);
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.checks label.soon { color: var(--muted); }
.checks label.soon input { cursor: not-allowed; }

.badge-soon {
  display: inline-block;
  white-space: nowrap;
  font-size: .6875rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .05rem .45rem;
  margin-left: .35rem;
}

.toggles { gap: .35rem; }

.stock-toggle {
  padding-bottom: .875rem;
  border-bottom: 1px solid var(--rule);
}
.stock-toggle label { font-weight: 600; color: var(--ink); }

.filters input[type="search"],
.filters input[type="number"],
.filters select {
  width: 100%;
  padding: .4rem .5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .875rem;
}

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

.actions button {
  background: var(--accent);
  color: var(--surface);
  border: 0;
  border-radius: var(--radius);
  padding: .45rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.actions a { color: var(--muted); font-size: .875rem; }

/* --- results ------------------------------------------------------------- */

.results-meta {
  margin: 0 0 .75rem;
  color: var(--muted);
  font-size: .8125rem;
}

.empty {
  padding: 2.5rem 0;
  color: var(--muted);
  max-width: 46ch;
}

.listing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.listing {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: .875rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}

/* Sold-out listings still show (that's the point), just visually set back --
   a shaded panel rather than hidden or styled like an error. */
.listing.is-oos {
  background: var(--surface);
  padding: .8rem .75rem;
  margin: 0 -.75rem;
  border-radius: var(--radius);
}

.listing-media {
  position: relative;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.listing-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: calc(var(--radius) * .6);
  background: var(--surface);
  display: block;
}

.is-oos .listing-thumb { filter: grayscale(70%); opacity: .7; }

/* the spool end -- a corner badge on the product photo when there is one,
   or the sole swatch (at full size) when there isn't */
.chip {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .18);
}

.listing-media:has(.listing-thumb) .chip {
  position: absolute;
  bottom: -3px;
  right: -3px;
  border: 2px solid var(--paper);
}

.is-oos .listing-media:has(.listing-thumb) .chip { border-color: var(--surface); }

.listing-media:not(:has(.listing-thumb)) .chip {
  width: 44px;
  height: 44px;
  border-radius: calc(var(--radius) * .6);
}

.listing-title {
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  display: inline-block;
  max-width: 62ch;
}
.listing-title:hover { text-decoration: underline; }

.listing-meta,
.listing-ship {
  margin: .2rem 0 0;
  font-size: .8125rem;
  color: var(--muted);
}

.listing-ship { color: var(--accent); }

.oos-badge {
  margin: .3rem 0 0;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--alert);
}

.listing-price {
  text-align: right;
  display: grid;
  gap: 0;
  min-width: 8.5rem;
}

.ppk {
  font-family: "Space Grotesk", Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.ppk-unit {
  font-size: .75rem;
  color: var(--muted);
  margin-top: -.1rem;
}

.abs {
  font-size: .8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
}

.deal {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: .15rem;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem 0;
  font-variant-numeric: tabular-nums;
}

/* --- content pages ------------------------------------------------------- */

.prose {
  max-width: 68ch;
  margin: 0 auto;
  padding: 2rem var(--space) 4rem;
}

.prose h1, .prose h2 {
  font-family: "Space Grotesk", Archivo, "Helvetica Neue", Arial, sans-serif;
}
.prose h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
.prose h2 { font-size: 1.1rem; margin-top: 2rem; }

.auth-page { max-width: 26rem; }

.auth-form {
  display: grid;
  gap: .5rem;
  margin-top: 1.25rem;
}
.auth-form label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-form input {
  padding: .55rem .65rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.auth-form button {
  margin-top: .5rem;
  background: var(--accent);
  color: var(--surface);
  border: 0;
  border-radius: var(--radius);
  padding: .55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.contact {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.contact h2 { margin-top: 0; }
.contact a { color: var(--accent); font-weight: 600; }

.error-page {
  text-align: center;
  padding-top: 4rem;
  padding-bottom: 6rem;
}

.error-code {
  font-family: "Space Grotesk", Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 4.5rem;
  font-weight: 700;
  line-height: 1;
  margin: 0;
  color: var(--accent2);
  letter-spacing: -0.03em;
}

.error-page h1 { margin: .5rem 0 .75rem; }
.error-page p { color: var(--muted); }

.error-home {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.error-home:hover { text-decoration: underline; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th, .table td {
  text-align: left;
  padding: .5rem .5rem .5rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 600; }

.state-on  { color: var(--accent); font-weight: 600; }
.state-off { color: var(--muted); }
.state-err { color: var(--alert); font-weight: 600; }

.inline-form { display: inline; }
.inline-form button {
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .15rem .5rem;
  font: inherit;
  font-size: .8125rem;
  color: var(--ink);
  cursor: pointer;
}

/* --- footer -------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--rule);
  padding: 1.25rem var(--space);
}
.footer p {
  max-width: 1120px;
  margin: 0 auto;
  color: var(--muted);
  font-size: .8125rem;
}
.footer p + p { margin-top: .35rem; }
.footer-ai { font-weight: 600; }

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 800px) {
  .masthead-inner { grid-template-columns: 1fr; }
  .masthead-nav { justify-content: flex-start; flex-wrap: wrap; }

  .layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .filters {
    position: static;
    max-height: none;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
  }

  .listing { grid-template-columns: 44px 1fr; }
  .listing-price {
    grid-column: 2;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
  }
  .ppk { font-size: 1.25rem; }
  .ppk-unit { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- scrollbars ------------------------------------------------------- */
/* Themed instead of the raw OS-default bars, on every scrollable region. */

.ticker,
.filters,
.checks {
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.ticker::-webkit-scrollbar,
.filters::-webkit-scrollbar,
.checks::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.ticker::-webkit-scrollbar-track,
.filters::-webkit-scrollbar-track,
.checks::-webkit-scrollbar-track {
  background: transparent;
}

.ticker::-webkit-scrollbar-thumb,
.filters::-webkit-scrollbar-thumb,
.checks::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: var(--radius);
}

.ticker::-webkit-scrollbar-thumb:hover,
.filters::-webkit-scrollbar-thumb:hover,
.checks::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
