/* Pezzi di contenuto: foto, link, domande (accordion), briciole, classe energetica, agenzia, pin della mappa. */

@layer components {
  /* ---------- Occhiello: la riga piccola verde sopra un titolo ---------- */
  .kicker {
    font-size: var(--step-small);
    font-weight: 600;
    color: var(--accent);

    &.danger { color: var(--heart); }
  }

  /* ---------- Elenco con le spunte (disegnate con il bordo: prendono il colore del tema) ---------- */
  .ticks {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;

    & li { position: relative; padding-left: 26px; }
    & li::before {
      content: "";
      position: absolute;
      left: 2px;
      top: .5em;
      width: 12px;
      height: 7px;
      border-left: 2px solid var(--accent);
      border-bottom: 2px solid var(--accent);
      transform: rotate(-45deg);
    }
  }

  /* ---------- Nessun risultato ---------- */
  .empty {
    padding: 40px 24px;
    border-radius: var(--r-md);
    background: var(--tint);

    & h2 { font-size: var(--step-lead); }
  }

  /* ---------- Paginazione ---------- */
  .pager { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; padding-top: 36px; }

  /* ---------- Foto ---------- */
  .pic {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-lg);
    background: var(--tint-2);

    & img { width: 100%; height: 100%; object-fit: cover; }
    &.md { border-radius: var(--r-md); }
    &.sm { border-radius: var(--r-sm); }
  }

  /* ---------- Link nel testo: sottolineato, la linea si accende al passaggio ---------- */
  .link {
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
    transition: text-decoration-color var(--dur-fast) var(--ease);

    &:hover { text-decoration-color: currentColor; }
    &.accent { color: var(--accent); }
  }

  /* ---------- Domande (details/summary nativi) ---------- */
  .qa {
    display: grid;
    gap: 12px;

    & details {
      border-radius: var(--r-md);
      box-shadow: inset 0 0 0 1px var(--line);
      transition: box-shadow var(--dur-fast) var(--ease);
    }
    & details[open] { box-shadow: inset 0 0 0 1px var(--ink-soft); }

    & summary {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      min-height: var(--field-h);
      padding: 18px 22px;
      font-family: var(--display);
      font-size: var(--step-lead);
      line-height: 1.2;
      letter-spacing: -0.01em;
      list-style: none;
      cursor: pointer;
    }
    & summary::-webkit-details-marker { display: none; }
    & summary::after {
      content: "";
      flex: none;
      width: 9px;
      height: 9px;
      border-right: 2px solid currentColor;
      border-bottom: 2px solid currentColor;
      transform: rotate(45deg) translateY(-3px);
      transition: transform .25s var(--ease);
    }
    & details[open] summary::after { transform: rotate(225deg) translateY(-3px); }
    & summary:hover { color: var(--accent); }

    & .answer { padding: 0 22px 22px; max-width: 70ch; }
  }

  /* ---------- Briciole ---------- */
  .crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--step-small);
    color: var(--ink-soft);

    & li + li::before { content: "›"; margin-right: 10px; }
    & a { text-decoration: none; }
    & a:hover { color: var(--ink); }
    & [aria-current="page"] { color: var(--ink); }
  }

  /* ---------- Classe energetica: sette caselle, quella dell'immobile accesa ---------- */
  .energy {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;

    & li {
      display: grid;
      place-items: center;
      height: 30px;
      border-radius: 6px;
      color: var(--on-ink);
      font-size: var(--step-small);
      font-weight: 600;
      opacity: .35;
    }
    & li.on { opacity: 1; transform: scaleY(1.2); }
    & li:nth-child(1) { background: var(--energy-a); }
    & li:nth-child(2) { background: var(--energy-b); }
    & li:nth-child(3) { background: var(--energy-c); color: var(--ink); }
    & li:nth-child(4) { background: var(--energy-d); color: var(--ink); }
    & li:nth-child(5) { background: var(--energy-e); color: var(--ink); }
    & li:nth-child(6) { background: var(--energy-f); }
    & li:nth-child(7) { background: var(--energy-g); }
  }

  /* ---------- Agenzia: logo, nome, link alla vetrina ---------- */
  .agency {
    display: grid;
    grid-template-columns: 88px 1fr;
    align-items: center;
    gap: 6px 18px;
    padding: 20px;
    border-radius: var(--r-lg);
    background: var(--tint);
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);

    &:hover { background: var(--tint-2); box-shadow: inset 0 0 0 1.5px var(--accent); }

    & img {
      grid-row: span 2;
      width: 88px;
      height: 88px;
      border-radius: var(--r-md);
      background: var(--ground);
      object-fit: contain;
    }
    & b {
      align-self: end;
      font-family: var(--display);
      font-size: var(--step-lead);
      font-weight: 500;
      line-height: 1.1;
      letter-spacing: -0.01em;
    }
    & .go { align-self: start; font-size: var(--step-small); font-weight: 600; color: var(--accent); }
    &:hover .go { text-decoration: underline; text-underline-offset: 4px; }
  }

  /* ---------- Pin della mappa: prezzo breve in una pillola con la punta ---------- */
  .pin {
    position: relative;
    display: inline-block;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: 600 13px/1 var(--font);
    font-variant-numeric: tabular-nums;
    cursor: pointer;

    & .p {
      position: relative;
      display: block;
      padding: 8px 11px;
      border-radius: var(--r-pill);
      background: var(--ground);
      white-space: nowrap;
      box-shadow: var(--shadow-pin);
      transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), scale .25s var(--ease-spring);
    }
    & .p::after {
      content: "";
      position: absolute;
      left: 50%;
      bottom: -5px;
      width: 10px;
      height: 10px;
      translate: -50% 0;
      rotate: 45deg;
      background: inherit;
      border-radius: 0 0 3px 0;
    }
    &:is(:hover, .is-hot) .p { background: var(--ink); color: var(--on-ink); scale: 1.08; }
    &.is-open .p { background: var(--accent); color: var(--on-ink); scale: 1.1; }
    &.is-seen:not(.is-hot, .is-open) .p { background: var(--tint-2); }
    &.is-fav .p::before { content: "♥"; margin-right: 5px; color: var(--heart); }
    &:is(.is-hot, .is-open) .p::before { color: currentColor; }
    &:focus-visible { outline: none; }
    &:focus-visible .p { outline: 3px solid var(--accent); outline-offset: 2px; }
  }
}
