/* ============================================================================
   stowage.css — the Properties & Handling view's own thin layer on top of mds.css.
   Prefix: stowage-

   The page is five phase sections (mds-groups--sections, MdsGroup), and inside each one the
   split this view exists for (issue #68): a scannable FACTS grid over a visually separate
   INSTRUCTIONS block. Everything systemic — the section head, its accent rule and icon badge —
   lives in mds.css; what is left here is the geometry of that split.
   ========================================================================= */

/* ---- the key-facts strip (issue #69) -------------------------------------------------------
   Six fixed slots above the phase groups - specific gravity, flash point, melting point, carriage
   temperature, max adjacent temperature, PPE level - so the answer to "what am I dealing with"
   is on screen before any scrolling starts.

   The grid is FIXED per breakpoint (2 / 3 / 6 columns), never auto-fit: the strip's whole value is
   that a given fact is always in the same place, and an auto-fitting track count would move it as
   the window resizes. Six columns need 1150px to stay honest, which is also where the app's wide
   layout starts. */
.stowage-keyfacts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;                       /* the hairline BETWEEN the cells, drawn by the background */
    margin: 0 0 var(--mds-space-5);
    padding: 1px;
    border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius);
    background: var(--mds-line);    /* shows through the 1px gaps as the divider grid */
    overflow: hidden;               /* so the cell corners follow the strip's radius */
}

@media (min-width: 768px)  { .stowage-keyfacts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1150px) { .stowage-keyfacts { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.stowage-keyfacts__fact {
    padding: var(--mds-space-2) var(--mds-space-3);
    background: var(--mds-surface);
}

/* Label first and quiet, value under it and loud - the same hierarchy the facts grid below uses,
   one step further: this is the one place on the page that may shout.

   The label WRAPS, it is never clipped. At 390px the strip is two columns, which leaves the label
   about 145px - and "MAX ADJACENT TEMP" needs more. The first draft cut it to "MAX ADJACENT ..."
   with an ellipsis and no title attribute, on the one class of device where a tooltip does not
   exist: an ellipsis is only a fallback when hovering is, and on a phone it is a dead end.

   Two lines are therefore reserved below 768px, where the second one is used: without the floor
   the value of a one-line label would start higher than its neighbour's and the strip would read
   as a ragged block instead of a row of facts. Above that width every label fits on one line
   (three columns leave ~215px, six leave ~175px), so the floor is lifted and nothing is padded. */
.stowage-keyfacts__label {
    margin: 0;
    color: var(--mds-muted);
    font-size: var(--mds-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    line-height: 15px;
    min-height: 30px;               /* two lines - the value keeps its baseline across the row */
    overflow-wrap: break-word;
}

@media (min-width: 768px) { .stowage-keyfacts__label { min-height: 0; } }

/* Two lines is the ceiling every value the strip can hold actually needs - measured over the live
   corpus, the longest is a flash point with its remark ("200 °C (LOWER LIMIT)"). The temperatures
   that would not fit are never printed here at all (see StowageKeyFacts: a value the recorded
   wording outruns is pointed at, not shortened), so the clamp guards against future content drift
   rather than biting today.

   It is deliberately NOT the recovery for a value that is too long: the cell's tooltip carries the
   recorded wording, and a tooltip is worth nothing on a phone, which is the only width where a
   value could clamp at all. Anything that must be readable is kept short enough to be readable -
   the clamp is a last line, not a plan. */
.stowage-keyfacts__value {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin: 2px 0 0;
    color: var(--mds-title);
    font-size: var(--mds-text-lg);
    line-height: 20px;
    font-weight: 600;
}

/* An absent value is muted and regular-weight wherever it appears (.stowage-none / .stowage-unknown
   below), but in the strip it must also stop SHOUTING: a dash at 16px semibold would read as the
   loudest thing in a row of real numbers. The pointer to a phase reads the same way - it is not an
   answer either. */
.stowage-keyfacts__value:has(.stowage-none),
.stowage-keyfacts__value:has(.stowage-unknown),
.stowage-keyfacts__value:has(.stowage-keyfacts__see) {
    font-size: var(--mds-text-sm);
    font-weight: 400;
}

.stowage-keyfacts__see { color: var(--mds-muted); font-style: italic; }

.stowage-groups {
    /* The label track of the facts grid: a floor, not a fixed width, so the values line up down
       a column instead of hanging off each label's own length. Measured on the rendered page at
       1280px, not guessed: the widest facts label is "Heated Adjacent Cargoes" at 169px (it shows
       on every cargo carrying IBC 16.6.1), so a shorter floor would let that one row's value
       scrape past the column while the rest line up. A still longer label keeps its full width —
       one ragged row beats a clipped label. Measured result: every label track is 175px and the
       values stand at 219 / 822px, in both columns and on all five sections. */
    --stowage-facts-label: 12.5em;   /* 175px */

    /* The prose labels are longer, and this is a fixed track rather than a floor (a paragraph
       needs a predictable left edge): "Phenomena during/after cleaning" measures 227px, so
       anything under it wraps that one label to two lines while the thirteen others stay on one. */
    --stowage-prose-label: 16.5em;   /* 231px */
}

/* ---- the sheet: facts block over instructions block ---------------------------------------
   The card carries no head (the section heading names it), so it is a pure container: two
   blocks, one gap. */
.stowage-sheet {
    display: grid;
    gap: var(--mds-space-4);
}

/* The quiet caption that names each block. An uppercase micro-caption, deliberately much
   quieter than the section head above it — it labels a block, it does not open a chapter.
   FACTS carries the darker ink of the two: the caption is the first mark of the block that
   leads (see the weight note below), INSTRUCTIONS stays muted. */
.stowage-block__caption {
    margin: 0 0 var(--mds-space-1-5);
    color: var(--mds-title);
    font-size: var(--mds-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.stowage-block--prose > .stowage-block__caption { color: var(--mds-muted); }

/* ---- FACTS: short labelled values, scannable ----------------------------------------------
   THE FACTS BLOCK LEADS. That is the whole point of the redesign (issue #68): the scalars are
   what gets copied into voyage instructions, the prose is the exception that needs a human. The
   first draft got the hierarchy backwards — a tinted prose box outweighed the plain fact rows, so
   an officer looking for "Max Adjacent Temp" had to route around a colored block to reach it.
   The weight now sits here: the value carries the page's large size and its darkest ink, one step
   above the body text and two above the prose block, and every fact row gets air to stand in. The
   label keeps the full body-text ink — the eye scans this block BY the label. */
.stowage-facts .mds-data__v {
    font-size: var(--mds-text-lg);
    line-height: 22px;
    color: var(--mds-title);
}
.stowage-facts td { padding-top: var(--mds-space-1-5); padding-bottom: var(--mds-space-1-5); }

/* Below 768px this is exactly the table it has always been (mobile-first: the card is the full
   width anyway). From 768px the rows lay out in COLUMNS instead of a narrow strip of labels with
   a desert beside it — pure display switching on the existing table, so the row markup, the row
   order and every kv fact the golden master reads are untouched (the #58 technique). */
@media (min-width: 768px) {
    .stowage-facts {
        display: grid;
        /* auto-fit over a 340px minimum, capped at TWO columns: these values are longer than the
           Summary's numbers (a temperature carries its source wording underneath), and a third
           track would break "Ambient to 45 °C / 113 °F" over two lines to win nothing. auto-fit
           collapses the empty track, so a phase with a single fact fills the whole row instead of
           leaving half of it white. */
        grid-template-columns: repeat(auto-fit, minmax(max(340px, (100% - var(--mds-space-7)) / 2), 1fr));
        column-gap: var(--mds-space-7);
    }
    /* Blazor builds the table WITHOUT the tbody an HTML parser would insert, a parsed copy of the
       same markup (bUnit, a static harness page) with one — display: contents makes the rows
       items of the table grid either way. */
    .stowage-facts > tbody { display: contents; }

    .stowage-facts tr {
        display: grid;
        grid-template-columns: minmax(var(--stowage-facts-label), max-content) minmax(0, 1fr);
        align-items: baseline;
        /* The ROW draws the rule now: label and value cell can differ in height (a temperature
           with its source line), and two cell borders at two heights read as a broken line. */
        border-bottom: 1px solid var(--mds-line);
    }
    .stowage-facts td { border-bottom: none; }
    /* the table-layout "shrink to the widest label" trick means nothing to a grid item */
    .stowage-facts .mds-data__k { width: auto; }
}

/* ---- INSTRUCTIONS: prose, quarantined ------------------------------------------------------
   The block IS the quarantine: whatever wraps to three lines belongs in here, and the reader can
   see at a glance where the numbers stop and the sentences start. The core's .mds-data--prose
   already flips the emphasis (bold key as the marker, regular-weight sentence); this adds the
   block, the reading measure and a label column that may wrap.

   The fill is NEUTRAL, not the brand tint it used to be. A teal box is a call for attention, and
   on this page attention belongs to the facts above it — the block only has to say "different
   material starts here", which the near-white shelf and the hairline do without competing. The
   text inside keeps the full body size: prose that is demoted must still be comfortable to read,
   it is just no longer the first thing seen. */
.stowage-block--prose {
    padding: var(--mds-space-2-5) var(--mds-space-3);
    border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius);
    background: var(--mds-canvas);
}

/* Label above sentence on a phone — a 15em label track next to a paragraph is unreadable at
   390px, and these labels are long ("Tank acceptance requirements"). Same geometry as the core
   .mds-deflist, applied to the data table because a kv row is what render parity reads. */
.stowage-prose { display: block; }
.stowage-prose > tbody { display: contents; }
.stowage-prose tr {
    display: block;
    padding: var(--mds-space-1) 0;
    border-bottom: 1px solid var(--mds-line);
}
.stowage-prose tr:last-child { border-bottom: none; }
.stowage-prose td { display: block; padding: 0; border-bottom: none; }
/* The bold navy key of the core prose variant is a heading-strength marker — right in a step list,
   too loud for fourteen of them stacked under a facts grid. It stays the marker (semibold, so the
   sentence still starts at a visible edge) but in the page's body ink. */
.stowage-prose .mds-data__k {
    width: auto;
    white-space: normal;
    margin-bottom: var(--mds-space-0-5);
    font-weight: 600;
    color: var(--mds-text);
}
.stowage-prose .mds-data__v { padding-left: 0; max-width: var(--mds-measure); }

/* ---- an instruction row with nothing in it -------------------------------------------------
   The row STAYS: customers orient by where a fact stands, so nothing disappears when there is no
   information (Robert's standing rule from the Summary redesign). Measured against the live
   corpus, 184 of 2 709 approved products are in the fully sparse state and 429 carry no
   description texts at all — roughly one cargo in fifteen, DIESEL OIL and ETHYLACETATE among
   them — so what these rows must not do is COST anything: no bold marker, no second line, no
   14px. A block of them then reads as a quiet register of what was asked, and the rows that do
   carry text are the only ones with weight in the block.
   Keyed off the "nothing recorded" dash StowageValue renders, so it can never drift from the
   vocabulary it mirrors (:has, already used in vessel-plan.css). */
.stowage-prose tr:has(.stowage-none) {
    display: flex;
    align-items: baseline;
    gap: var(--mds-space-2);
    padding: 0;
}
.stowage-prose tr:has(.stowage-none) .mds-data__k,
.stowage-prose tr:has(.stowage-none) .mds-data__v {
    margin-bottom: 0;
    font-size: var(--mds-text-xs);
    font-weight: 400;
    color: var(--mds-muted);
}

@media (min-width: 768px) {
    .stowage-prose tr {
        display: grid;
        grid-template-columns: minmax(0, var(--stowage-prose-label)) minmax(0, 1fr);
        column-gap: var(--mds-space-4);
        align-items: baseline;
    }
    .stowage-prose .mds-data__k { margin-bottom: 0; }
}

/* ---- the vocabulary of a value -------------------------------------------------------------
   Three states, three shapes on screen (issue #68, carrying the #65 derivation): a value reads
   as a value, "Unknown" says the question was researched and has no answer, and the dash says
   nothing was ever recorded. Both kinds of absence are muted and regular-weight, so a real value
   is what the eye lands on — but they stay two different words, never the same dash. */
.stowage-none,
.stowage-unknown {
    color: var(--mds-muted);
    font-weight: 400;
}
.stowage-unknown { font-style: italic; }

/* The source wording under a derived answer: kept because it is the only place a qualifier
   ("(Discharge location Rotterdam)", the Fahrenheit half) survives, quiet because the structured
   answer above it is the one to scan. */
.stowage-source {
    display: block;
    margin-top: 2px;
    color: var(--mds-muted);
    font-size: var(--mds-text-xs);
    font-weight: 400;
}
