/*
 * Instagram Caption Generator - tool-specific styles.
 *
 * Composes the shared primitives in tools.css (.tool-form-card,
 * .mode-toggle, .text-input, .primary-btn, .results-region,
 * .tone-pills, .quota-banner, .upgrade-banner, .toasts, etc.). Only the
 * tool-specific pieces live here:
 *   - 3-tab mode-toggle overrides (the shared slide rule only handles 2)
 *   - image dropzone + thumbnail
 *   - focus-keyword live preview + brand-voice field
 *   - caption cards
 *   - the 125-char "show more" hook visualization (the headline UI)
 *   - editable Hook / Body / CTA structure breakdown
 *   - hashtag tier pills
 *
 * Brand color: yellow-500 (#eab308).
 */

:root {
    --icg-brand:        #eab308;
    --icg-brand-strong: #ca9a04;
    --icg-brand-tint:   #fef9e7;
    --icg-brand-tint-2: #fdf3c7;
    --icg-ink:          #1f2430;
    --icg-muted:        #6b7280;
    --icg-line:         #e5e7eb;
    --icg-ok:           #15803d;
    --icg-ok-bg:        #ecfdf3;
    --icg-warn:         #b45309;
    --icg-warn-bg:      #fff7ed;
    --icg-danger:       #b91c1c;
    --icg-danger-bg:    #fef2f2;
}

/* ---- Focus rings tuned to the brand ---- */
.instagram-caption-generator .text-input:focus,
#icg-form-card .text-input:focus,
#icg-form-card .icg-file-input:focus {
    border-color: var(--icg-brand);
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.18);
    outline: none;
}

/* ===================================================================
 * 3-tab mode toggle. The shared .mode-toggle::before slider is
 * hardcoded for data-mode="bulk" with translateX(100%); a 3-tab
 * toggle needs an explicit per-tab translateX and each button must
 * flex: 1 1 0 so the three share the width equally (otherwise the
 * sliding pill drifts off the centered label).
 * =================================================================== */
.icg-mode-toggle { min-width: 0; }
.icg-mode-toggle .mode-btn {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
}
.icg-mode-toggle::before {
    width: 33.333%;
    transition: transform 0.22s ease;
}
.icg-mode-toggle[data-mode="image"]::before { transform: translateX(0); }
.icg-mode-toggle[data-mode="topic"]::before { transform: translateX(100%); }
.icg-mode-toggle[data-mode="url"]::before   { transform: translateX(200%); }

/* ---- Field labels / hints ---- */
.icg-field-label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--icg-ink);
    margin: 0 0 6px;
}
.icg-optional {
    font-weight: 400;
    color: var(--icg-muted);
    font-size: 0.82rem;
}
.icg-field-hint {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: var(--icg-muted);
}
.icg-mode-body { margin-top: 16px; }

.icg-char-count {
    margin-top: 6px;
    font-size: 0.76rem;
    color: var(--icg-muted);
    text-align: right;
}
.icg-char-count.is-warning { color: var(--icg-warn); }
.icg-char-count.is-danger  { color: var(--icg-danger); }

/* ---- Image dropzone ---- */
.icg-dropzone {
    position: relative;
    border: 2px dashed var(--icg-line);
    border-radius: 12px;
    background: #fafafa;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.icg-dropzone:hover,
.icg-dropzone:focus,
.icg-dropzone.is-dragover {
    border-color: var(--icg-brand);
    background: var(--icg-brand-tint);
    outline: none;
}
.icg-file-input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.icg-dropzone-icon {
    width: 40px; height: 40px;
    color: var(--icg-brand-strong);
    margin-bottom: 8px;
}
.icg-dropzone-text {
    margin: 0;
    font-size: 0.95rem;
    color: var(--icg-ink);
}
.icg-dropzone-link {
    color: var(--icg-brand-strong);
    font-weight: 600;
    text-decoration: underline;
}
.icg-dropzone-hint {
    margin: 6px 0 0;
    font-size: 0.78rem;
    color: var(--icg-muted);
}
.icg-dropzone-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
}
/* Mandatory: a flex element toggled via the [hidden] attribute needs an
 * explicit [hidden] override, since display:flex beats the UA [hidden]
 * rule (the hidden_attribute_with_flex trap). */
.icg-dropzone-preview[hidden] { display: none; }
.icg-thumb {
    width: 84px; height: 84px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--icg-line);
    background: #fff;
    flex: 0 0 auto;
}
.icg-thumb-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.icg-thumb-name {
    font-size: 0.88rem;
    color: var(--icg-ink);
    word-break: break-all;
}
.icg-thumb-remove {
    align-self: flex-start;
    background: none;
    border: 1px solid var(--icg-line);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.78rem;
    color: var(--icg-danger);
    cursor: pointer;
}
.icg-thumb-remove:hover { background: var(--icg-danger-bg); border-color: var(--icg-danger); }

.feedback-msg {
    margin: 8px 0 0;
    font-size: 0.82rem;
    color: var(--icg-muted);
}
.feedback-msg.is-warn { color: var(--icg-warn); }

/* ---- Shared options (focus keyword + brand voice) ---- */
.icg-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 18px;
}
.icg-option-cell { min-width: 0; }
/* Inputs inside the column-flex cells need a fixed flex-basis so the
 * shared .text-input { flex: 1 1 320px } does not become a 320px height
 * (the text_input_flex_basis_height trap). */
.icg-input-line,
.icg-topic-input,
.icg-brand-voice-input {
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.icg-kw-preview {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--icg-ink);
    min-height: 1.2em;
}
.icg-kw-preview.is-empty { display: none; }
.icg-kw-preview-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--icg-muted);
    margin-right: 6px;
}
.icg-kw-stat { white-space: nowrap; }
.icg-kw-stat-muted { color: var(--icg-muted); }

/* ---- Submit row ---- */
.icg-submit-row {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.icg-submit-hint {
    margin: 0;
    font-size: 0.8rem;
    color: var(--icg-muted);
}

/* ---- Progress bar ---- */
.icg-progress-bar-track {
    height: 8px;
    background: var(--icg-brand-tint-2);
    border-radius: 999px;
    overflow: hidden;
}
.icg-progress-bar-fill {
    height: 100%;
    width: 10%;
    background: linear-gradient(90deg, var(--icg-brand), var(--icg-brand-strong));
    border-radius: 999px;
    transition: width 0.4s ease;
}
.icg-whimsy-msg {
    margin: 10px 0 0;
    font-size: 0.9rem;
    color: var(--icg-muted);
    text-align: center;
}

/* ---- Results body ---- */
.icg-results-body { padding: 18px 22px 4px; }
.icg-source-subhead {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: var(--icg-brand-tint);
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--icg-ink);
    word-break: break-word;
}
/* Mandatory [hidden] guard: this is a flex element toggled via the
 * [hidden] attribute (the hidden_attribute_with_flex trap). */
.icg-source-subhead[hidden] { display: none; }
.icg-source-subhead-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--icg-brand-strong);
    flex: 0 0 auto;
}

.icg-caption-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ---- Caption card ---- */
.icg-caption-card {
    border: 1px solid var(--icg-line);
    border-radius: 12px;
    background: #fff;
    padding: 16px;
    transition: opacity 0.15s ease;
}
.icg-caption-card.is-regenerating { opacity: 0.55; }

.icg-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.icg-card-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.icg-goal-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--icg-muted);
}
/* Goal badge colors. Deliberately NOT the brand yellow (which is the
 * hook-state/affordance accent) so the goal reads as a category, not a
 * status. Five distinct hues. */
.icg-goal-badge.is-goal-engagement   { background: #2563eb; }  /* blue */
.icg-goal-badge.is-goal-sales        { background: #059669; }  /* green */
.icg-goal-badge.is-goal-storytelling { background: #7c3aed; }  /* violet */
.icg-goal-badge.is-goal-educational  { background: #0891b2; }  /* cyan */
.icg-goal-badge.is-goal-humor        { background: #db2777; }  /* pink */

.icg-char-total {
    font-size: 0.76rem;
    color: var(--icg-muted);
}
.icg-card-header-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}
.icg-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: 1px solid var(--icg-line);
    border-radius: 7px;
    background: #fff;
    color: var(--icg-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.icg-icon-btn svg { width: 15px; height: 15px; }
.icg-icon-btn:hover { border-color: var(--icg-brand); color: var(--icg-brand-strong); background: var(--icg-brand-tint); }
.icg-icon-btn.is-copied { border-color: var(--icg-ok); color: var(--icg-ok); background: var(--icg-ok-bg); }
.icg-icon-btn.is-busy { opacity: 0.5; pointer-events: none; }
.icg-regen-btn.is-busy svg { animation: icg-spin 0.7s linear infinite; }
@keyframes icg-spin { to { transform: rotate(360deg); } }

/* ===================================================================
 * The 125-char "show more" hook visualization (the headline UI).
 * A color-coded status strip (label + dot) above the caption grades
 * the opener; the caption text itself renders uniform full-strength
 * (see the note below the .icg-hook-pre rule).
 * =================================================================== */
.icg-hook-viz {
    border-radius: 10px;
    border: 1px solid var(--icg-line);
    overflow: hidden;
    margin-bottom: 14px;
}
.icg-hook-viz-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    font-size: 0.74rem;
    font-weight: 600;
    border-bottom: 1px solid var(--icg-line);
}
.icg-hook-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--icg-muted);
}
.icg-hook-pre {
    padding: 12px 14px;
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
/* The caption preview is uniform full-strength text. It is NOT split or
 * greyed at Instagram's ~125-char cutoff: any partial color change landed
 * mid-sentence / mid-paragraph and read as a rendering glitch. The
 * hook-state strip below is the sole opener-quality indicator. */

/* Hook-state coloring applies ONLY to the status strip + dot, never to
 * the caption text itself. */
.icg-hook-viz.is-green .icg-hook-viz-label { background: var(--icg-ok-bg); color: var(--icg-ok); }
.icg-hook-viz.is-green .icg-hook-dot       { background: var(--icg-ok); }

.icg-hook-viz.is-amber .icg-hook-viz-label { background: var(--icg-warn-bg); color: var(--icg-warn); }
.icg-hook-viz.is-amber .icg-hook-dot       { background: var(--icg-warn); }

.icg-hook-viz.is-red .icg-hook-viz-label   { background: var(--icg-danger-bg); color: var(--icg-danger); }
.icg-hook-viz.is-red .icg-hook-dot         { background: var(--icg-danger); }

/* ---- Structure breakdown (editable Hook / Body / CTA) ---- */
.icg-breakdown {
    border: 1px solid var(--icg-line);
    border-radius: 10px;
    margin-bottom: 14px;
    background: #fafafa;
}
.icg-breakdown-summary {
    cursor: pointer;
    list-style: none;
    padding: 9px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--icg-ink);
    position: relative;
}
.icg-breakdown-summary::-webkit-details-marker { display: none; }
.icg-breakdown-summary::after {
    content: '\25BE';
    position: absolute;
    right: 12px;
    color: var(--icg-muted);
    transition: transform 0.15s ease;
}
.icg-breakdown[open] .icg-breakdown-summary::after { transform: rotate(180deg); }
.icg-edit-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 10px;
    align-items: start;
    padding: 8px 12px 10px;
}
.icg-edit-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--icg-muted);
    text-transform: uppercase;
    padding-top: 8px;
}
.icg-edit-input {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    border: 1px solid var(--icg-line);
    border-radius: 7px;
    padding: 7px 9px;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--icg-ink);
    background: #fff;
    min-height: 40px;
    overflow: hidden;
}
.icg-edit-input:focus {
    border-color: var(--icg-brand);
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.18);
    outline: none;
}

/* ---- Hashtag tier display ---- */
.icg-hashtags { margin-top: 2px; }
.icg-hashtags-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--icg-muted);
    margin-bottom: 8px;
}
.icg-tier-key { display: inline-flex; gap: 5px; }
.icg-tier-chip {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}
.icg-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.icg-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px 3px 8px;
    border-radius: 999px;
    font-size: 0.82rem;
    text-decoration: none;
    border: 1px solid transparent;
    transition: filter 0.12s ease;
}
.icg-tag:hover { filter: brightness(0.96); text-decoration: none; }
.icg-tag-hash { font-weight: 700; opacity: 0.7; }
.icg-tag-tier {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.65);
}

/* Tier colors (broad=red, niche=amber, micro=green per the spec). The
 * .icg-tier-chip in the legend reuses the same palette. */
.icg-tag.is-broad, .icg-tier-chip.is-broad {
    background: var(--icg-danger-bg);
    color: var(--icg-danger);
    border-color: #fbcaca;
}
.icg-tag.is-niche, .icg-tier-chip.is-niche {
    background: var(--icg-warn-bg);
    color: var(--icg-warn);
    border-color: #fcd9a8;
}
.icg-tag.is-micro, .icg-tier-chip.is-micro {
    background: var(--icg-ok-bg);
    color: var(--icg-ok);
    border-color: #b7e4c7;
}

/* ---- Honest-framing caveat ---- */
.icg-caveat {
    margin-top: 18px;
    border-top: 1px solid var(--icg-line);
    padding-top: 12px;
}
.icg-caveat summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--icg-ink);
}
.icg-caveat p {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: var(--icg-muted);
    line-height: 1.5;
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
    .icg-options { grid-template-columns: 1fr; gap: 14px; }
    .icg-results-body { padding: 14px 14px 4px; }
    .icg-edit-row { grid-template-columns: 1fr; gap: 4px; }
    .icg-edit-label { padding-top: 0; }
    .icg-dropzone-preview { flex-direction: column; align-items: flex-start; }
}
