/* ============================================================
   pvi-detail-page.css
   Self-contained stylesheet for pvi-detail-page.html.

   This page replaces the standard master frame with its own
   shell, so frame-level base rules live here alongside the
   page-specific rules. All colors reference :root variables;
   no legacy palette hex, no universal reset.
   ============================================================ */

:root {
    --grey:        #d1d1d1;   /* labels / neutral cells        */
    --dark:        #2e2e2e;   /* dark headers / dark text      */
    --mid-grey:    #7d7d7d;   /* page + section backgrounds    */
    --green:       #28a745;   /* positive / save button        */
    --green-hover: #218838;   /* save button hover             */
    --dull-red:    #c0392b;   /* negative results              */
    --orange:      #f39c12;   /* mixed category headers        */
    --blue:        #5bc0de;   /* selection / findings headers  */
    --white:       #ffffff;

    /* Secondary-button + focus tokens. Mirrors the master frame's
       interaction cluster; declared locally because this page runs
       its own shell and never loads pvi-master-frame.css. */
    --mid-grey-hover:  #6a6a6a;
    --focus-ring-blue: rgba(91, 192, 222, .25);
}

/* ---- Frame-level base ------------------------------------- */

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

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: var(--mid-grey);
    color: var(--dark);
}

/* ---- Page layout ------------------------------------------ */

.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--mid-grey);
}

.image-section {
    flex: 0 0 40%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    background-color: var(--mid-grey);
}

.image-wrapper {
    position: relative;
    max-width: 100%;
    /* --score-color is supplied inline from <<main_score_color>>;
       falls back to transparent if unresolved or empty */
    border: 10px solid var(--score-color, transparent);
}

.main-image {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    background-color: transparent;
    position: relative;
    pointer-events: none;
}

.overlay-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.info-section {
    flex: 1;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
    overflow-y: auto;
    background-color: var(--mid-grey);
}

/* ---- Portrait header + summary rows ----------------------- */

.portrait-header {
    padding: 15px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    border-radius: 6px;
    background-color: var(--dark);
    color: var(--grey);
}

/* ---- Data rows -------------------------------------------- */

.data-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px;
    margin-bottom: 2px;
    min-height: 40px;
    align-items: stretch;
}

.field-column1,
.field-column2,
.field-column3 {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 4px;
    font-size: 15px;
    line-height: 1.2;
    word-wrap: break-word;
    background-color: var(--grey);
    color: var(--dark);
}

.field-column1 {
    font-weight: 500;
}

.field-column3 {
    justify-content: flex-start;
    /* Checkbox + adjusted-value pill share the cell; wrap the pill
       under the checkbox on narrow viewports instead of overflowing.
       Harmless on cells with a single child. */
    flex-wrap: wrap;
    gap: 4px 10px;
}

/* Engine-driven cell background. --bg is supplied inline from a
   <<*_color>> marker; falls back to the neutral grey if unresolved. */
.dyn-bg {
    background-color: var(--bg, var(--grey));
}

/* Value cells with an engine-driven background use white text. */
.field-column2.dyn-bg {
    color: var(--white);
}

.field-value {
    display: inline;
}

/* ---- Reviewer adjustments (section 44.6) ------------------ */
/* Adjusted value shown beside a checkbox, filled from a
   <<*_adjusted>> marker. The engine resolves the marker to the
   empty string when the category has no active adjustment, and
   :empty then removes the pill, so the markup needs no gate.
   The span must stay whitespace-free for :empty to match.
   Every accept moves a value toward good (score to max, penalty
   cleared, eye open), hence the positive green. The arrow is
   CSS-drawn so the markup carries no glyphs. */

.field-adjusted {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    line-height: 1.4;
    white-space: nowrap;
    background-color: var(--green);
    color: var(--white);
}

.field-adjusted::before {
    content: '\2192';        /* rightwards arrow: engine value -> adjusted */
    margin-right: 4px;
}

.field-adjusted:empty {
    display: none;
}

/* ---- Category sections ------------------------------------ */

.category-section {
    margin-bottom: 15px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-top: 8px;
    margin-bottom: 5px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    color: var(--white);
    /* --cat-color is supplied inline from a <<*_category_color>>
       marker; falls back to blue if unresolved or empty */
    background-color: var(--cat-color, var(--blue));
}

/* New Findings header is a fixed blue (no engine color marker). */
.category-header--findings {
    --cat-color: var(--blue);
}

.category-title {
    text-transform: none;
}

/* CSS-driven disclosure arrow — no Unicode glyphs in the markup */
.category-arrow::before {
    content: '\25B6';        /* right-pointing triangle (collapsed) */
}

.category-arrow.open::before {
    content: '\25BC';        /* down-pointing triangle (expanded)   */
}

.category-content {
    display: none;
    width: 100%;
    margin-top: 2px;
    padding: 0;
    border-radius: 0 0 6px 6px;
}

.category-content.is-open {
    display: block;
}

/* ---- Form controls ---------------------------------------- */

.field-checkbox {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

.field-dropdown {
    width: 100%;
    min-width: 120px;
    padding: 4px 6px;
    border: 1px solid var(--dark);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.2;
    background-color: var(--mid-grey);
    color: var(--white);
}

/* ---- Bottom-of-page action buttons ------------------------ */
/* Local copy of the master frame's §7 pattern. This page runs its
   own shell, so it cannot inherit pvi-master-frame.css — keep this
   block in sync with §7 if that section changes.

   One button or two, same markup:
     <div class="save-section">
       <button type="submit" class="save-btn">Primary Action</button>
       <a href="..." class="save-btn save-btn-secondary">Return to Menu</a>
     </div>

   width:100% was removed from .save-btn: a full-width button cannot
   share a row, which would break the two-button layout. Add
   .save-btn-wide for the old full-width look on single-button pages. */

.save-section {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    padding: 20px;
    margin-top: 8px;
}

.save-btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    background-color: var(--green);
    color: var(--white);
    transition: background-color .15s;
}

.save-btn:hover,
.save-btn:focus {
    background-color: var(--green-hover);
    color: var(--white);
    text-decoration: none;
}

.save-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 .2rem var(--focus-ring-blue);
}

.save-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.save-btn-wide {
    width: 100%;
    max-width: 400px;
}

.save-btn-secondary {
    background-color: var(--mid-grey);
}

.save-btn-secondary:hover,
.save-btn-secondary:focus {
    background-color: var(--mid-grey-hover);
}

/* ---- Narrow-viewport adjustments -------------------------- */

@media (max-width: 768px) {
    /* Stack the action row full-width so a pair of buttons is tappable */
    .save-section {
        flex-direction: column;
    }
    .save-section > .save-btn {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .field-dropdown {
        min-width: 80px;
        font-size: 12px;
    }
}

@media (max-width: 320px) {
    .field-dropdown {
        min-width: 70px;
        font-size: 11px;
    }
}
