/* Adesso Ci Penso — fogli di stile completi.
   Tutto è scoped sotto #acp per non collidere con il CSS di WordPress / Enfold. */

#acp {
  --acp-bg: #faf8f3;
  --acp-bg-card: #ffffff;
  --acp-bg-soft: #fff8d8;
  --acp-bg-rules: #f8f1d9;
  --acp-bg-overlay: rgba(20, 16, 12, 0.55);

  --acp-ink: #2a2a2a;
  --acp-ink-soft: #555555;
  --acp-muted: #888888;
  --acp-line: #d8d0bf;
  --acp-line-strong: #2a2a2a;
  --acp-accent: #6b3f1d;
  --acp-accent-ink: #ffffff;
  --acp-gold: #c79a2c;

  --acp-ok: #2f9e44;
  --acp-warn: #e0a020;
  --acp-bad: #c0392b;

  --acp-radius: 12px;
  --acp-radius-sm: 8px;
  --acp-shadow: 0 6px 20px rgba(20, 16, 12, 0.08);

  --acp-gap: 12px;
  --acp-gap-sm: 8px;
  --acp-pad: 16px;

  --acp-serif: Georgia, "Times New Roman", serif;
  --acp-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  font-family: var(--acp-sans);
  color: var(--acp-ink);
  background: var(--acp-bg);
  max-width: 1320px;
  margin: 12px auto;
  padding: 0 14px 24px;
  line-height: 1.4;
}

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

/* ---------- Titolo ---------- */
.acp-titolo {
  text-align: center;
  margin-bottom: 10px;
}
.acp-titolo h1 {
  font-family: var(--acp-serif);
  font-size: clamp(22px, 3.5vw, 34px);
  letter-spacing: 0.02em;
  margin: 0 0 2px;
  color: var(--acp-ink);
}
.acp-sottotitolo {
  margin: 0;
  color: var(--acp-ink-soft);
  font-style: italic;
  font-size: 13px;
}

/* ---------- Regole ---------- */
.acp-regole {
  background: var(--acp-bg-rules);
  border: 1px solid var(--acp-line);
  border-radius: var(--acp-radius);
  padding: 8px 14px;
  margin-bottom: var(--acp-gap-sm);
  box-shadow: var(--acp-shadow);
}
.acp-regole > summary {
  cursor: pointer;
  font-size: 14px;
  list-style: none;
  outline-offset: 4px;
}
.acp-regole > summary::-webkit-details-marker { display: none; }
.acp-regole > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 160ms ease;
}
.acp-regole[open] > summary::before { transform: rotate(90deg); }
.acp-regole-corpo p {
  margin: 8px 0;
  line-height: 1.55;
  font-size: 15px;
}

/* ---------- Topbar ---------- */
.acp-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--acp-gap-sm);
  background: var(--acp-bg-card);
  border: 1px solid var(--acp-line);
  border-radius: var(--acp-radius);
  padding: 10px 14px;
  margin-bottom: var(--acp-gap-sm);
  box-shadow: var(--acp-shadow);
}

/* Timer */
.acp-timer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  --acp-timer-color: var(--acp-ok);
}
.acp-timer-ring {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  transform: rotate(-90deg);
}
.acp-timer-track {
  fill: none;
  stroke: var(--acp-line);
  stroke-width: 6;
}
.acp-timer-bar {
  fill: none;
  stroke: var(--acp-timer-color);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 175.93;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 800ms linear, stroke 200ms ease;
}
.acp-timer-testo {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.acp-timer-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--acp-muted);
}
#acp-timer {
  font-family: var(--acp-serif);
  font-size: 28px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  color: var(--acp-timer-color);
}
.acp-timer[data-stato="warn"] { --acp-timer-color: var(--acp-warn); }
.acp-timer[data-stato="bad"]  { --acp-timer-color: var(--acp-bad); animation: acp-pulse 1s ease-in-out infinite; }
.acp-timer[data-stato="paused"] { --acp-timer-color: var(--acp-muted); }

@keyframes acp-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* Azioni topbar */
.acp-azioni {
  display: flex;
  flex-wrap: wrap;
  gap: var(--acp-gap-sm);
  justify-content: flex-end;
}

/* ---------- Pulsanti ---------- */
.acp-btn {
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--acp-line-strong);
  background: var(--acp-bg-card);
  color: var(--acp-ink);
  border-radius: var(--acp-radius-sm);
  padding: 8px 12px;
  transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.acp-btn:hover { background: #f1ece0; }
.acp-btn:active { transform: translateY(1px); }
.acp-btn:focus-visible {
  outline: 2px solid var(--acp-accent);
  outline-offset: 2px;
}
.acp-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: var(--acp-bg-card);
  transform: none;
}
.acp-btn-primary {
  background: var(--acp-accent);
  color: var(--acp-accent-ink);
  border-color: var(--acp-accent);
}
.acp-btn-primary:hover { background: #5a3416; }
.acp-btn-ghost {
  background: transparent;
  border-color: var(--acp-line);
  color: var(--acp-ink-soft);
}
.acp-btn-ghost:hover { background: rgba(0, 0, 0, 0.04); }

/* ---------- Frase in costruzione ---------- */
.acp-frase-box {
  background: var(--acp-bg-soft);
  border: 1px solid var(--acp-line);
  border-radius: var(--acp-radius);
  padding: 10px 14px;
  margin-bottom: var(--acp-gap-sm);
  box-shadow: var(--acp-shadow);
}
.acp-frase-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--acp-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.acp-frase-titolo { font-weight: 600; }
.acp-contatore { font-variant-numeric: tabular-nums; }
.acp-frase {
  font-family: var(--acp-serif);
  font-size: clamp(17px, 2.4vw, 24px);
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  min-height: 1.4em;
  color: var(--acp-ink);
}

/* ---------- Griglia carte ---------- */
.acp-griglia {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--acp-gap);
  margin-bottom: var(--acp-gap);
}
.acp-colonna {
  position: relative;
  background: var(--acp-bg-card);
  border: 1px solid var(--acp-line-strong);
  border-radius: var(--acp-radius);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--acp-shadow);
  opacity: 0;
  transform: translateY(8px);
  animation: acp-card-in 360ms ease forwards;
  transition: opacity 200ms ease, transform 200ms ease;
}
.acp-colonna:nth-child(1) { animation-delay: 40ms; }
.acp-colonna:nth-child(2) { animation-delay: 80ms; }
.acp-colonna:nth-child(3) { animation-delay: 120ms; }
.acp-colonna:nth-child(4) { animation-delay: 160ms; }
.acp-colonna:nth-child(5) { animation-delay: 200ms; }
.acp-colonna:nth-child(6) { animation-delay: 240ms; }
.acp-colonna:nth-child(7) { animation-delay: 280ms; }

@keyframes acp-card-in {
  to { opacity: 1; transform: none; }
}

.acp-colonna h3 {
  margin: 0 0 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--acp-ink-soft);
  text-align: center;
}
.acp-colonna .acp-btn {
  width: 100%;
  padding: 6px 6px;
  font-size: 13px;
  background: #fbf6e9;
  border-color: #c8b78e;
  text-align: center;
  line-height: 1.2;
}
.acp-colonna .acp-btn:hover { background: #f3eacc; }

.acp-colonna.usata {
  opacity: 0.5;
  transform: scale(0.985);
}
.acp-colonna.usata .acp-btn { background: #f5f5f0; }

/* Carta jolly */
.acp-colonna.jolly {
  border: 2px solid var(--acp-gold);
  background: linear-gradient(160deg, #fffbe9 0%, #f6e9b6 100%);
}
.acp-colonna.jolly h3 { color: var(--acp-accent); }
.acp-jolly-badge {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--acp-gold);
  border-radius: var(--acp-radius-sm);
  background: rgba(255, 255, 255, 0.85);
  color: var(--acp-accent);
}

/* ---------- Bacheca ---------- */
.acp-bacheca {
  background: var(--acp-bg-card);
  border: 1px solid var(--acp-line);
  border-radius: var(--acp-radius);
  padding: var(--acp-pad);
  box-shadow: var(--acp-shadow);
}
.acp-bacheca-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--acp-gap-sm);
  margin-bottom: var(--acp-gap-sm);
}
.acp-bacheca-head h2 {
  margin: 0;
  font-family: var(--acp-serif);
  font-size: 22px;
}
.acp-bacheca-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.acp-bacheca-item {
  border: 1px solid var(--acp-line);
  border-radius: var(--acp-radius-sm);
  padding: 12px 14px;
  background: #fbfaf6;
}
.acp-bacheca-frase {
  font-family: var(--acp-serif);
  font-size: 18px;
  margin-bottom: 4px;
}
.acp-bacheca-meta {
  font-size: 12px;
  color: var(--acp-muted);
}
.acp-bacheca-vuota {
  text-align: center;
  color: var(--acp-muted);
  font-style: italic;
  padding: 16px;
}

/* ---------- Popup ---------- */
.acp-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--acp-bg-overlay);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: acp-fade-in 180ms ease;
}
.acp-popup-overlay[hidden] { display: none; }

@keyframes acp-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes acp-slide-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.acp-popup {
  background: var(--acp-bg-card);
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  overflow: auto;
  border-radius: var(--acp-radius);
  border: 1px solid var(--acp-line);
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  animation: acp-slide-up 220ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
.acp-popup h2 {
  margin: 0 0 8px;
  font-family: var(--acp-serif);
  font-size: 22px;
}
.acp-popup-testo {
  white-space: pre-line;
  line-height: 1.55;
  color: var(--acp-ink-soft);
  margin: 0 0 12px;
}
.acp-popup input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--acp-line-strong);
  border-radius: var(--acp-radius-sm);
  background: #fbfaf6;
  margin: 8px 0 0;
}
.acp-popup input[type="text"]:focus {
  outline: 2px solid var(--acp-accent);
  outline-offset: 1px;
}
.acp-popup-azioni {
  display: flex;
  gap: var(--acp-gap-sm);
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
}

.acp-opzioni-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.acp-opzione-btn {
  text-align: left;
  width: 100%;
}

.acp-verb-group {
  border: 1px solid var(--acp-line);
  border-radius: var(--acp-radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  background: #fbfaf6;
}
.acp-verb-group h4 {
  margin: 0 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--acp-ink-soft);
}
.acp-verb-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.acp-verb-buttons .acp-btn {
  width: auto;
  padding: 6px 10px;
  font-size: 14px;
}

/* ---------- Toast ---------- */
.acp-toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100000;
  pointer-events: none;
  width: min(420px, calc(100% - 32px));
}
.acp-toast {
  pointer-events: auto;
  background: var(--acp-ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: acp-toast-in 220ms ease, acp-toast-out 220ms ease forwards;
  animation-delay: 0s, var(--acp-toast-out-delay, 3s);
  text-align: center;
  max-width: 100%;
}
.acp-toast.success { background: var(--acp-ok); }
.acp-toast.warning { background: var(--acp-warn); color: #1a1a1a; }
.acp-toast.error   { background: var(--acp-bad); }

@keyframes acp-toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes acp-toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Responsive ---------- */
/* Sotto 820px (laptop stretti / tablet landscape) -> 4 colonne, due righe */
@media (max-width: 820px) {
  .acp-griglia { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .acp-colonna:nth-child(n) { animation-delay: 0ms; }
  .acp-colonna:nth-child(1), .acp-colonna:nth-child(2),
  .acp-colonna:nth-child(3), .acp-colonna:nth-child(4) { animation-delay: 60ms; }
  .acp-colonna:nth-child(5), .acp-colonna:nth-child(6),
  .acp-colonna:nth-child(7) { animation-delay: 160ms; }
}
/* Tablet portrait / mobile largo */
@media (max-width: 600px) {
  #acp { margin: 8px auto; padding: 0 10px 24px; }
  .acp-griglia { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .acp-topbar { padding: 10px; }
  .acp-azioni { width: 100%; justify-content: stretch; }
  .acp-azioni .acp-btn { flex: 1; padding: 8px 6px; font-size: 13px; }
  .acp-bacheca-head h2 { font-size: 18px; }
  .acp-popup { padding: 16px; }
}
/* Mobile stretto */
@media (max-width: 420px) {
  .acp-griglia { grid-template-columns: 1fr; }
  .acp-titolo h1 { font-size: 22px; }
  #acp-timer { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .acp-colonna,
  .acp-toast,
  .acp-popup,
  .acp-popup-overlay { animation: none; }
  .acp-timer[data-stato="bad"] { animation: none; }
}
