/* ─────────────────────────────────────────
   CSS VARIABLES
   Original light vars kept so all JS-rendered
   inline styles (var(--green), var(--red), etc.)
   continue to resolve correctly on white cards.
   Only dark-navy surfaces are replaced.
───────────────────────────────────────── */
:root {
    /* Surfaces — replaced to match site */
    --bg:       #f5f9f8;
    --surface:  #ffffff;
    --surface2: #f5f9f8;

    /* Accent — site brand green replaces navy/cyan */
    --brand:        #4eb39a;
    --brand-dark:   #3a9b83;
    --brand-deep:   #0e2d27;
    --brand-mid:    #1a4a3d;
    --accent-light: #e1f5ee;

    /* Semantic colours — kept exactly (used in JS-rendered HTML) */
    --green:    #059669;
    --green-bg: #ecfdf5;
    --red:      #dc2626;
    --red-bg:   #fef2f2;
    --orange:   #d97706;
    --orange-bg:#fffbeb;
    --yellow:   #ca8a04;
    --yellow-bg:#fefce8;
    --blue:     #2563eb;
    --blue-bg:  #eff6ff;

    /* Borders & text — kept exactly (used in JS-rendered HTML) */
    --border:  rgba(78,179,154,0.18);
    --border2: rgba(78,179,154,0.3);
    --text0:   #1a2e2b;
    --text1:   #334155;
    --text2:   #5f7a74;
    --text3:   #94aaa6;

    /* Font stacks — DM Sans/Mono loaded by header.php */
    --syne:  'DM Sans', sans-serif;
    --dm:    'DM Sans', sans-serif;
    --code:  'DM Mono', monospace;

    /* Navy — mapped for legacy inline refs in JS renders */
    --navy:  #0e2d27;
    --navy2: #1a4a3d;
    --cyan:       #4eb39a;
    --cyan2:      #3a9b83;
    --cyan-dim:   rgba(78,179,154,0.1);
}

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

/* ─────────────────────────────────────────
   PAGE WRAPPER
───────────────────────────────────────── */
.s3v-page {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--text0);
    padding-bottom: 5rem;
}

/* ─────────────────────────────────────────
   HERO — dark card matching site pattern
───────────────────────────────────────── */
.s3v-head {
    background: linear-gradient(145deg, #0e2d27 0%, #1a4a3d 60%, #0e3530 100%);
    padding: 0;
    position: relative;
    overflow: hidden;
}
.s3v-head::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 60% 80% at 80% 50%, rgba(78,179,154,0.1) 0%, transparent 60%);
    pointer-events: none;
}
.s3v-head-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}
.s3v-hero-left { flex: 1; min-width: 260px; }

/* Eyebrow pill */
.s3v-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--code);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6fd1b3;
    background: rgba(78,179,154,0.12);
    border: 1px solid rgba(78,179,154,0.3);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 1rem;
}
.s3v-eyebrow::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #6fd1b3;
    animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

.s3v-head h1 {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: .6rem;
}
.s3v-head h1 span { color: #6fd1b3; }
.s3v-head p {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.5);
    line-height: 1.75;
    max-width: 460px;
}

/* Trust items */
.s3v-trust { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1.25rem; }
.s3v-trust-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
}
.s3v-trust-item svg { width: 13px; height: 13px; stroke: #6fd1b3; fill: none; flex-shrink: 0; }

/* Score ring */
.s3v-score-ring { flex-shrink: 0; text-align: center; }
.ring-svg { width: 120px; height: 120px; }
.ring-label { font-family: var(--code); font-size: 28px; font-weight: 700; fill: #fff; }
.ring-sub { font-family: var(--code); font-size: 0.65rem; color: rgba(255,255,255,.4); letter-spacing: .05em; margin-top: 2px; }

/* ─────────────────────────────────────────
   INNER LAYOUT
───────────────────────────────────────── */
.s3v-inner { max-width: 1100px; margin: 0 auto; padding: 2rem; }

/* ─────────────────────────────────────────
   INPUT PANEL — white card
───────────────────────────────────────── */
.input-panel {
    background: var(--surface);
    border-radius: 14px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s;
}
.input-panel:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }

.input-panel-head {
    background: #f5f9f8;
    padding: .9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.panel-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #0e2d27;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-title svg { width: 15px; height: 15px; stroke: #3a9b83; fill: none; stroke-width: 1.5; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Primary button — brand green */
.btn-primary {
    background: var(--brand);
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: #0e2d27;
    cursor: pointer;
    transition: background .15s, transform .12s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.btn-primary:hover   { background: var(--brand-dark); transform: translateY(-1px); }
.btn-primary:active  { transform: scale(.98); }
.btn-primary:disabled{ background: #e1f5ee; color: #94aaa6; cursor: not-allowed; transform: none; }
.btn-primary svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }

/* Ghost button (Clear / Export) */
.btn-ghost {
    background: transparent;
    border: 1px solid rgba(78,179,154,0.3);
    border-radius: 8px;
    padding: 9px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text2);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.btn-ghost:hover { background: #e1f5ee; border-color: var(--brand); color: var(--brand-dark); }
.btn-ghost svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }

/* Outline button (unused on new light bg but kept for parity) */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 8px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text2);
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn-outline svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }

.input-body { padding: 1.25rem 1.5rem; }

/* Bucket name row */
.bucket-row {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.bucket-label {
    font-family: var(--code);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text2);
    white-space: nowrap;
}
.bucket-input {
    flex: 1;
    min-width: 180px;
    background: #f5f9f8;
    border: 1px solid rgba(78,179,154,0.2);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: var(--code);
    font-size: 0.82rem;
    color: var(--text0);
    outline: none;
    transition: border-color .2s;
}
.bucket-input:focus { border-color: var(--brand); background: #fff; }
.bucket-input::placeholder { color: var(--text3); }

/* Policy textarea — keep dark for code legibility */
.s3v-textarea {
    width: 100%;
    min-height: 220px;
    background: #0e2d27;
    border: 1px solid rgba(78,179,154,0.2);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    font-family: var(--code);
    font-size: 0.78rem;
    color: #e1f5ee;
    resize: vertical;
    outline: none;
    line-height: 1.7;
    tab-size: 2;
    transition: border-color .2s;
}
.s3v-textarea::placeholder { color: rgba(255,255,255,.2); }
.s3v-textarea:focus { border-color: rgba(78,179,154,.5); }

/* Sample row */
.sample-row {
    display: flex;
    gap: 8px;
    margin-top: .75rem;
    flex-wrap: wrap;
    align-items: center;
}
.sample-lbl { font-size: 0.72rem; color: var(--text3); font-family: var(--code); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.sample-btn {
    font-size: 0.7rem;
    font-family: var(--code);
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid rgba(78,179,154,0.2);
    background: #f5f9f8;
    color: var(--text2);
    cursor: pointer;
    transition: all .15s;
}
.sample-btn:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--accent-light); }

/* ─────────────────────────────────────────
   RESULTS
───────────────────────────────────────── */
#s3v-results { display: none; }

/* Score banner */
.score-banner {
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: box-shadow 0.2s;
}
.score-banner:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.06); }

.score-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    flex-shrink: 0;
    font-family: 'DM Mono', monospace;
    font-weight: 700;
    font-size: 1.6rem;
    line-height: 1;
}
.score-circle.score-a { background: #ecfdf5; color: #059669; border: 3px solid #059669; }
.score-circle.score-b { background: #eff6ff; color: #2563eb; border: 3px solid #2563eb; }
.score-circle.score-c { background: #fffbeb; color: #d97706; border: 3px solid #d97706; }
.score-circle.score-d { background: #fff7ed; color: #ea580c; border: 3px solid #ea580c; }
.score-circle.score-f { background: #fef2f2; color: #dc2626; border: 3px solid #dc2626; }
.score-circle span { font-size: 0.68rem; font-family: 'DM Sans', sans-serif; font-weight: 400; color: inherit; opacity: .7; margin-top: 1px; }

.score-meta { flex: 1; }
.score-meta h2 { font-size: 1.1rem; font-weight: 700; color: var(--text0); margin-bottom: .3rem; }
.score-meta p  { font-size: 0.82rem; color: var(--text2); line-height: 1.6; }

.score-counts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: .75rem; }
.score-pill {
    font-size: 0.68rem;
    font-weight: 600;
    font-family: var(--code);
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid;
}
.pill-critical { background: var(--red-bg);    color: var(--red);    border-color: rgba(220,38,38,.3); }
.pill-high     { background: #fff7ed;           color: #ea580c;       border-color: rgba(234,88,12,.3); }
.pill-medium   { background: var(--orange-bg);  color: var(--orange); border-color: rgba(217,119,6,.3); }
.pill-low      { background: var(--yellow-bg);  color: var(--yellow); border-color: rgba(202,138,4,.3); }
.pill-info     { background: var(--blue-bg);    color: var(--blue);   border-color: rgba(37,99,235,.3); }
.pill-pass     { background: var(--green-bg);   color: var(--green);  border-color: rgba(5,150,105,.3); }

/* Section heading */
.s3v-section { margin-bottom: 2rem; }
.s3v-section-title {
    font-family: var(--code);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.s3v-section-title::after { content: ''; flex: 1; height: 1px; background: rgba(78,179,154,0.15); }

/* ─────────────────────────────────────────
   FINDING CARDS — white with collapse
───────────────────────────────────────── */
.finding-list { display: flex; flex-direction: column; gap: 10px; }

.finding-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow .15s;
}
.finding-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.07); }

.finding-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
}
.finding-sev {
    font-family: var(--code);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 1px;
    border: 1px solid;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.sev-critical { background: var(--red-bg);    color: var(--red);    border-color: rgba(220,38,38,.3); }
.sev-high     { background: #fff7ed;           color: #ea580c;       border-color: rgba(234,88,12,.3); }
.sev-medium   { background: var(--orange-bg);  color: var(--orange); border-color: rgba(217,119,6,.3); }
.sev-low      { background: var(--yellow-bg);  color: var(--yellow); border-color: rgba(202,138,4,.3); }
.sev-info     { background: var(--blue-bg);    color: var(--blue);   border-color: rgba(37,99,235,.3); }
.sev-pass     { background: var(--green-bg);   color: var(--green);  border-color: rgba(5,150,105,.3); }

.finding-text { flex: 1; }
.finding-title { font-size: 0.875rem; font-weight: 600; color: var(--text0); margin-bottom: 3px; }
.finding-desc  { font-size: 0.78rem; color: var(--text2); line-height: 1.6; }
.finding-chevron { color: var(--text3); transition: transform .2s; flex-shrink: 0; margin-top: 2px; }
.finding-card.open .finding-chevron { transform: rotate(90deg); }

.finding-body {
    display: none;
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border);
}
.finding-card.open .finding-body { display: block; }

.finding-section-lbl {
    font-family: var(--code);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text3);
    margin: .9rem 0 .4rem;
}

/* Code block — keep dark for readability */
.finding-code {
    background: #0e2d27;
    border-radius: 8px;
    padding: .75rem 1rem;
    font-family: var(--code);
    font-size: 0.75rem;
    color: #94a3b8;
    overflow-x: auto;
    line-height: 1.6;
    white-space: pre;
}
.finding-code .hl-key   { color: #7dd3fc; }
.finding-code .hl-val   { color: #86efac; }
.finding-code .hl-warn  { color: #fca5a5; background: rgba(239,68,68,.1); border-radius: 2px; padding: 0 2px; }
.finding-code .hl-str   { color: #fcd34d; }

.remediation-box {
    background: #f0fdf4;
    border: 1px solid rgba(5,150,105,.2);
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: 0.78rem;
    color: #065f46;
    line-height: 1.7;
    margin-top: .75rem;
}
.remediation-box strong { font-weight: 700; display: block; margin-bottom: .25rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; color: #059669; }

/* ─────────────────────────────────────────
   STATEMENT CARDS
───────────────────────────────────────── */
.stmt-grid { display: flex; flex-direction: column; gap: 10px; }
.stmt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.stmt-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: .9rem 1.25rem;
    background: #f5f9f8;
    border-bottom: 1px solid var(--border);
}
.stmt-id { font-family: var(--code); font-size: 0.78rem; font-weight: 600; color: var(--text0); flex: 1; }
.stmt-effect {
    font-family: var(--code);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.effect-allow { background: var(--green-bg); color: var(--green); border: 1px solid rgba(5,150,105,.25); }
.effect-deny  { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(220,38,38,.25); }

.stmt-body { padding: 1rem 1.25rem; }
.stmt-row { display: flex; gap: 1rem; margin-bottom: .6rem; flex-wrap: wrap; }
.stmt-field { flex: 1; min-width: 140px; }
.stmt-field-label { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); font-family: var(--code); margin-bottom: 4px; }
.stmt-field-val { font-family: var(--code); font-size: 0.75rem; color: var(--text1); line-height: 1.6; word-break: break-all; }
.stmt-field-val .warn-val { color: var(--red); font-weight: 600; }
.stmt-field-val .ok-val   { color: var(--green); }

/* ─────────────────────────────────────────
   PERMISSION MATRIX
───────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; }
.perm-matrix {
    border-collapse: collapse;
    width: 100%;
    min-width: 520px;
    font-size: 0.75rem;
}
.perm-matrix th {
    padding: .5rem .75rem;
    text-align: left;
    font-family: var(--code);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text2);
    background: #eaf4f1;
    border-bottom: 2px solid rgba(78,179,154,0.2);
    white-space: nowrap;
}
.perm-matrix td {
    padding: .5rem .75rem;
    border-bottom: 1px solid rgba(78,179,154,0.08);
    font-family: var(--code);
    font-size: 0.75rem;
    color: var(--text1);
    vertical-align: middle;
}
.perm-matrix tr:hover td { background: #f5f9f8; }
.perm-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    border: 1px solid;
    margin: 2px 2px;
    white-space: nowrap;
}
.chip-allow { background: var(--green-bg); color: var(--green); border-color: rgba(5,150,105,.25); }
.chip-deny  { background: var(--red-bg);   color: var(--red);   border-color: rgba(220,38,38,.25); }
.chip-wild  { background: #fff7ed; color: #ea580c; border-color: rgba(234,88,12,.3); }
.chip-cross { background: var(--blue-bg); color: var(--blue); border-color: rgba(37,99,235,.3); }

/* ─────────────────────────────────────────
   COMPLIANCE GRID
───────────────────────────────────────── */
.compliance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.comp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: box-shadow 0.2s;
}
.comp-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.05); }
.comp-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.comp-icon.pass { background: var(--green-bg); }
.comp-icon.fail { background: var(--red-bg); }
.comp-icon.warn { background: var(--orange-bg); }
.comp-name   { font-size: 0.82rem; font-weight: 600; color: var(--text0); margin-bottom: 2px; }
.comp-detail { font-size: 0.72rem; color: var(--text2); line-height: 1.5; }

/* ─────────────────────────────────────────
   NO-POLICY PLACEHOLDER
───────────────────────────────────────── */
.no-policy {
    background: var(--surface);
    border: 2px dashed rgba(78,179,154,0.25);
    border-radius: 14px;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text3);
}
.no-policy-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.no-policy h3 { font-size: 1rem; font-weight: 700; color: var(--text2); margin-bottom: .4rem; }
.no-policy p  { font-size: 0.82rem; }

/* ─────────────────────────────────────────
   SEO / FAQ CARD
───────────────────────────────────────── */
.seo-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.75rem 2rem;
    margin-top: 2rem;
}
.seo-block h2 { font-size: 1.1rem; font-weight: 700; color: var(--text0); margin-bottom: .5rem; }
.seo-block p  { font-size: 0.875rem; color: var(--text2); line-height: 1.8; }
.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.faq-card { background: #f5f9f8; border: 1px solid rgba(78,179,154,0.15); border-radius: 10px; padding: 1rem 1.1rem; }
.faq-q { font-size: 0.875rem; font-weight: 600; color: var(--text0); margin-bottom: .4rem; }
.faq-a { font-size: 0.82rem; color: var(--text2); line-height: 1.7; }

/* ─────────────────────────────────────────
   TOAST
───────────────────────────────────────── */
.s3v-toast {
    position: fixed; bottom: 2rem; right: 2rem;
    background: #0e2d27;
    border: 1px solid rgba(78,179,154,0.35);
    border-radius: 10px;
    padding: .7rem 1.2rem;
    font-size: 0.82rem;
    font-family: var(--code);
    color: #e1f5ee;
    z-index: 999;
    transform: translateY(60px); opacity: 0;
    transition: all .3s; pointer-events: none;
}
.s3v-toast.show { transform: translateY(0); opacity: 1; }

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 680px) {
    .s3v-inner { padding: 1rem; }
    .s3v-head-inner { padding: 1.75rem 1.25rem; }
    .input-panel-head { flex-direction: column; align-items: flex-start; }
    .finding-head { flex-wrap: wrap; }
    .seo-block { padding: 1.25rem; }
}
