/*
 * srl-target-display.css — public target table ([target_schedule]).
 *
 * OWNED by mu-plugins/srl-target-display.php; enqueued by srl_target_display_enqueue_assets()
 * (handle "srl-target-display", version = file mtime). CC-274 moved these rules out of the
 * former inline <style> block (render_styles()) and added the six-column / phone layout.
 *
 * MOBILE-FIRST (project policy): the BASE rules are the phone layout (< 600px), where each
 * table row becomes a stacked block and <thead> is hidden. The desktop table is layered on
 * via the single min-width:600px query at the bottom. CSS variables cannot be used inside
 * @media conditions, so 600px is written literally (same breakpoint as srl-forms.css).
 *
 * Every rule is scoped under .srl-target-schedule so the generic column class names
 * (srl-date-col etc.) cannot leak into other tables.
 */

.srl-target-schedule {
    --srl-tt-muted: #666;          /* date line (phone) and Notes text */
    --srl-tt-rule: #ddd;           /* hairline between blocks (phone) */
    --srl-tt-header-rule: #000;    /* header underline (desktop, unchanged) */
    --srl-tt-zebra: #f5f5f5;       /* even-row background (desktop, unchanged) */
    --srl-tt-thumb-border: #ccc;   /* tappable thumbnail frame (phone) */
    --srl-tt-secondary-size: 0.9em;

    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

/* ------------------------------------------------------------------ */
/* Base = PHONE (< 600px): one block per date, no horizontal scroll.   */
/* ------------------------------------------------------------------ */

.srl-target-schedule,
.srl-target-schedule tbody {
    display: block;
}

.srl-target-schedule thead {
    display: none;
}

/*
 * Block grid. Text runs down the left; the thumbnail sits top-right spanning the text rows;
 * Notes runs full width underneath. Yards and Time share one line (their own two columns).
 * Grid rows with nothing in them collapse to zero height, so empty lines disappear.
 */
.srl-target-schedule tbody tr {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas:
        "date  date  date   target"
        "name  name  name   target"
        "yards time  .      target"
        "notes notes notes  notes";
    /* CC-274.1: no column-gap. A gap is drawn even beside an empty auto track, which
       indented a lone "Time" value; spacing now comes from the cells themselves. */
    column-gap: 0;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--srl-tt-rule);
    background: transparent;
}

.srl-target-schedule tbody tr:last-child {
    border-bottom: none;
}

/* No target to show (make-up days, awards): one full-width text column, no thumbnail gap. */
.srl-target-schedule tbody tr.srl-no-target {
    grid-template-areas:
        "date  date  date   date"
        "name  name  name   name"
        "yards time  .      ."
        "notes notes notes  notes";
}

.srl-target-schedule tbody td {
    display: block;
    padding: 0;
    min-width: 0;          /* let long words wrap instead of widening the grid */
    overflow-wrap: anywhere;
}

.srl-target-schedule tbody td.srl-empty,
.srl-target-schedule tbody tr.srl-no-target td.srl-target-col {
    display: none;
}

.srl-target-schedule tbody td.srl-date-col {
    grid-area: date;
    font-size: var(--srl-tt-secondary-size);
    color: var(--srl-tt-muted);
}

.srl-target-schedule tbody td.srl-name-col {
    grid-area: name;
    font-size: 1.15em;
    font-weight: bold;
    margin-top: 2px;
}

.srl-target-schedule tbody td.srl-yards-col {
    grid-area: yards;
    margin-top: 4px;
    white-space: nowrap;
}

.srl-target-schedule tbody td.srl-time-col {
    grid-area: time;
    margin-top: 4px;
    white-space: nowrap;
}

/* Labels come from each cell's data-label attribute (markup), not from CSS strings. */
.srl-target-schedule tbody td.srl-yards-col::before,
.srl-target-schedule tbody td.srl-time-col::before {
    content: attr(data-label) " ";
    color: var(--srl-tt-muted);
}

/* "Yards 15 · Time 25": the dot appears only when both values are present.
   (\00a0 = a non-breaking space before the dot, since there is no column gap.) */
.srl-target-schedule tbody td.srl-time-col.srl-after-yards::before {
    content: "\00a0· " attr(data-label) " ";
}

/* CC-274.1: Time with no Yards beside it (row has no yards, or the season has no Yards
   column at all) moves into the first slot, so it starts flush left with no orphan dot. */
.srl-target-schedule tbody td.srl-time-col:not(.srl-after-yards) {
    grid-area: yards;
}

.srl-target-schedule tbody td.srl-target-col {
    grid-area: target;
    text-align: center;
    margin-left: 12px;     /* CC-274.1: replaces the former 12px column-gap */
}

/* Thumbnail as a tap target: >= 56px square including padding, light frame, rounded. */
.srl-target-schedule tbody td.srl-target-col img {
    display: block;
    box-sizing: border-box;
    min-width: 56px;
    min-height: 56px;
    height: auto;
    padding: 4px;
    border: 1px solid var(--srl-tt-thumb-border);
    border-radius: 6px;
    background: #fff;
}

.srl-target-schedule tbody td.srl-target-col a {
    display: block;
}

.srl-target-schedule tbody td.srl-notes-col {
    grid-area: notes;
    margin-top: 8px;
    font-size: var(--srl-tt-secondary-size);
    color: var(--srl-tt-muted);
}

/* ------------------------------------------------------------------ */
/* DESKTOP / TABLET (>= 600px): restore the table, six columns.        */
/* ------------------------------------------------------------------ */

@media (min-width: 600px) {
    .srl-target-schedule {
        display: table;
    }

    .srl-target-schedule thead {
        display: table-header-group;
    }

    .srl-target-schedule tbody {
        display: table-row-group;
    }

    .srl-target-schedule tbody tr,
    .srl-target-schedule tbody tr.srl-no-target {
        display: table-row;
        padding: 0;
        border-bottom: none;
    }

    .srl-target-schedule tbody tr.even-row {
        background-color: var(--srl-tt-zebra);
    }

    .srl-target-schedule tbody tr.odd-row {
        background-color: #ffffff;
    }

    .srl-target-schedule thead th {
        border-bottom: 2px solid var(--srl-tt-header-rule);
        padding: 10px;
        text-align: left;
        font-weight: bold;
    }

    .srl-target-schedule tbody td,
    .srl-target-schedule tbody td.srl-empty,
    .srl-target-schedule tbody tr.srl-no-target td.srl-target-col {
        display: table-cell;
        padding: 15px 10px;
        vertical-align: middle;
        margin: 0;
        overflow-wrap: normal;
    }

    .srl-target-schedule tbody td.srl-date-col,
    .srl-target-schedule tbody td.srl-name-col {
        font-size: inherit;
        font-weight: normal;
        color: inherit;
    }

    .srl-target-schedule tbody td.srl-yards-col::before,
    .srl-target-schedule tbody td.srl-time-col::before,
    .srl-target-schedule tbody td.srl-time-col.srl-after-yards::before {
        content: none;
    }

    /* The season page's content column is narrow (~680px), so the theme's word breaking
       was splitting dates ("09/09/2|6") and "Instructi|ons" mid-word. Break only at spaces;
       the auto table layout then widens a column to its longest word instead. */
    .srl-target-schedule thead th,
    .srl-target-schedule tbody td {
        word-break: normal;
        overflow-wrap: normal;
        hyphens: manual;
    }

    .srl-target-schedule tbody td.srl-date-col {
        white-space: nowrap;
    }

    /*
     * CC-274.1: Yards, Time and Notes are rendered only when the season has data for them,
     * so the table has 4, 5 or 6 columns. render() marks the <table> with srl-has-yards /
     * srl-has-time-limit / srl-has-notes, and Notes gets whatever share the rendered narrow
     * columns leave, so every set sums to 100% and Notes stays the widest column:
     *   6 cols: Date 11 | Name 20 | Target 12 | Yards 9 | Time 8 | Notes 40
     *   5 cols: Date 11 | Name 20 | Target 12 | Yards 9 | Notes 48
     *   5 cols: Date 11 | Name 20 | Target 12 | Time 8  | Notes 49
     *   4 cols: Date 11 | Name 20 | Target 12 | Notes 57
     * (An unsized Notes column was tried first; the browser handed the slack to Yards/Time
     * instead, leaving Notes at ~27%, so the share is explicit.) With no Notes column at
     * all the sized columns sum to under 100% and the browser spreads the slack.
     */
    .srl-target-schedule .srl-date-col   { width: 11%; }
    .srl-target-schedule .srl-name-col   { width: 20%; }
    .srl-target-schedule .srl-target-col { width: 12%; text-align: center; }
    .srl-target-schedule .srl-yards-col  { width: 9%; }
    .srl-target-schedule .srl-time-col   { width: 8%; }

    .srl-target-schedule.srl-has-notes .srl-notes-col                                  { width: 57%; }
    .srl-target-schedule.srl-has-notes.srl-has-yards .srl-notes-col                    { width: 48%; }
    .srl-target-schedule.srl-has-notes.srl-has-time-limit .srl-notes-col               { width: 49%; }
    .srl-target-schedule.srl-has-notes.srl-has-yards.srl-has-time-limit .srl-notes-col { width: 40%; }

    /* Notes is secondary text: a little smaller and lighter than Name. */
    .srl-target-schedule tbody td.srl-notes-col {
        font-size: var(--srl-tt-secondary-size);
        color: var(--srl-tt-muted);
    }

    /* Thumbnail back to its plain desktop presentation (75px via the width attribute). */
    .srl-target-schedule tbody td.srl-target-col img {
        display: inline-block;
        min-width: 0;
        min-height: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        background: transparent;
    }

    .srl-target-schedule tbody td.srl-target-col a {
        display: inline;
    }
}
