/* ===== Ingredient Decoder — page styles =====
   Builds on style.css design tokens (--primary, --radius, shadows, Outfit).
   RTL is handled via [dir="rtl"] overrides at the bottom. */

/* The `hidden` attribute must win over any author `display` (e.g. flex). */
[hidden] { display: none !important; }

.decode-main {
  min-height: calc(100vh - var(--header-h));
  padding: calc(var(--header-h) + 32px) 0 64px;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--primary-bg) 0%, transparent 55%),
    var(--bg);
}

.decode-container {
  max-width: 640px;
}

/* ---- Intro ---- */
.decode-intro {
  text-align: center;
  margin-bottom: 28px;
}
.decode-title {
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 10px;
}
.decode-sub {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 34ch;
  margin: 0 auto;
}

/* ---- Uploader ---- */
.decode-drop {
  width: 100%;
  border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
  font-family: inherit;
}
.decode-drop:hover,
.decode-drop:focus-visible {
  border-color: var(--primary);
  background: var(--primary-bg);
  outline: none;
}
.decode-drop:active { transform: scale(0.99); }
.decode-cam {
  width: 44px;
  height: 44px;
  color: var(--primary);
}
.decode-drop-main {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.decode-drop-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 30ch;
  line-height: 1.5;
}

/* Uploaded images — the main focus once added.
   One photo = large; two or three sit side-by-side and shrink to fit. */
.decode-previews {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.decode-preview {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.decode-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.decode-thumb-x {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(17,24,39,0.72);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
/* Small green "add another photo" box (no camera icon), sits under the photos */
.decode-add-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}
.decode-add-more:hover { border-color: var(--primary); }
.decode-add-plus { font-size: 1.3rem; line-height: 1; }

.decode-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.upload-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 32ch;
  line-height: 1.5;
  margin: 0;
}

/* Prominent primary action */
.decode-go {
  width: 100%;
  max-width: 360px;
  padding: 17px 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 10px 26px var(--primary-glow), var(--shadow-md);
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.decode-go:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px var(--primary-glow);
}
.decode-go:active { transform: translateY(0); }
.decode-reset {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.decode-reset:hover { color: var(--text-secondary); }

/* ---- Loading ---- */
.decode-loading {
  text-align: center;
  padding: 56px 0;
}
.decode-spinner {
  width: 46px; height: 46px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 3px solid var(--primary-bg);
  border-top-color: var(--primary);
  animation: decode-spin 0.9s linear infinite;
}
@keyframes decode-spin { to { transform: rotate(360deg); } }
.decode-loading-text {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ---- Result ---- */
.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  overflow: hidden;
}

.result-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.result-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.result-name {
  font-size: 1.28rem;
  font-weight: 800;
  color: var(--text);
  margin: 2px 0 4px;
  letter-spacing: -0.01em;
}
.result-headline {
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

/* Judy's take — the emotional center, deliberately distinct */
.judys-take {
  position: relative;
  background: linear-gradient(160deg, var(--primary-bg), color-mix(in srgb, var(--primary-bg) 40%, var(--bg)));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  margin-bottom: 22px;
}
.judys-take-label {
  display: inline-block;
  font-family: 'Caveat', 'Gveret Levin AlefAlefAlef', cursive;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.judys-take-body {
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
}

/* Ingredients */
.result-ings + .result-ings { margin-top: 24px; }
.result-ings-title {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 12px;
}
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-item {
  border-bottom: 1px solid var(--border);
}
.ing-item:last-child { border-bottom: none; }
.ing-btn {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  text-align: start;
  padding: 13px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
}
.ing-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
}
.ing-chev {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s var(--ease);
}
.ing-item.is-open .ing-chev { transform: rotate(180deg); }
.ing-detail {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s var(--ease);
}
.ing-detail-inner {
  padding: 0 0 14px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-secondary);
}
.ing-plain { color: var(--text-muted); font-size: 0.85rem; display: block; margin-bottom: 3px; }

.result-disclaimer {
  margin: 22px 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.decode-again-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 22px;
}
.decode-share {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.decode-share:hover { border-color: var(--primary); color: var(--primary); }
.decode-share svg { width: 17px; height: 17px; }

/* ---- State (errors/empty) ---- */
.decode-state {
  text-align: center;
  padding: 48px 0;
}
.decode-state-emoji { font-size: 2.6rem; margin: 0 0 12px; }
.decode-state-text {
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 32ch;
  margin: 0 auto 22px;
}

/* ---- Soft CTA ---- */
.decode-cta {
  text-align: center;
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
.decode-cta-text {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  max-width: 30ch;
  margin: 0 auto 8px;
}
.decode-cta-link {
  display: inline-block;
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 20px;
}
.decode-cta-link:hover { text-decoration: underline; }
.decode-store { justify-content: center; }

/* ---- RTL ---- */
[dir="rtl"] .decode-sub,
[dir="rtl"] .decode-drop-hint { text-align: center; }
[dir="rtl"] .ing-btn { text-align: start; }
[dir="rtl"] .decode-thumb-x { right: auto; left: 4px; }

@media (max-width: 480px) {
  .result-card { padding: 20px 16px; }
  .decode-main { padding-top: calc(var(--header-h) + 20px); }
}
