/* Media Junkbox Tracker: phone layer (MediaJunkbox design system tokens from app.css).
 * Loaded after app.css with media="(max-width: 768px)", so nothing here can reach tablets or desktop.
 * Rules here win over app.css on equal specificity because this file comes last; no @media needed.
 * Same rule as app.css: no inline styles (CSP).
 */

:root { --m-gutter: 16px; --m-nav: 76px; --m-safe: env(safe-area-inset-bottom, 0px); }

/* ---------- Shell ---------- */
body { padding-bottom: calc(var(--m-nav) + var(--m-safe)); }
.bottom-nav { height: calc(var(--m-nav) + var(--m-safe)); padding-bottom: var(--m-safe); }
.bottom-nav a { min-height: 48px; }
.page { padding: 8px var(--m-gutter) 24px; }
.page-head { align-items: flex-start; gap: 12px; }
.page-head > div:first-child { min-width: 0; }
.page-actions { width: 100%; }
.page-actions:empty { display: none; }
.page-title { overflow-wrap: anywhere; }
/* The dark frame continues on phones: the top bar is a black band with the wordmark in white and the gold avatar. */
.mobile-bar { background: var(--header-bg); margin: -8px calc(-1 * var(--m-gutter)) 0; padding: 8px var(--m-gutter);
  border-bottom: 3px solid var(--mjb-gold); }
.mobile-bar .avatar { width: 44px; height: 44px; font-size: 14px; }
.icon-btn { width: 44px; height: 44px; }

/* ---------- Cards and forms ---------- */
.card--pad-lg { padding: 16px; gap: 16px; }
.card--pad { padding: 16px; }
.card__head { flex-wrap: wrap; padding: 12px 16px; gap: 8px 12px; }
.card__head .right { margin-left: auto; }
.form-actions { flex-wrap: wrap; flex-direction: row; }
.form-actions .btn { flex: 1 1 auto; }
.form-actions .btn--primary { flex: 1 1 100%; order: 9; }
.input:focus, .select:focus, .textarea:focus { background: var(--content1); }
.textarea { min-height: 88px; }
.btn { white-space: normal; text-align: center; line-height: 18px; }
.checkbox { min-height: 36px; }
.checkbox input { width: 20px; height: 20px; flex-shrink: 0; }
.toggle-row { gap: 16px; align-items: flex-start; }
.toggle-row__text { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.toggle-row > .switch { margin-top: 2px; }
.toggle-row > .nowrap .input { width: 96px; }
.list-row { flex-wrap: wrap; padding: 12px 16px; gap: 10px 16px; }
.list-row > .toggle-row__text { flex: 1 1 200px; }
.list-row > form.row { width: 100%; }
.list-row > form.row .btn { flex: 1 1 auto; }
.kv { flex-wrap: wrap; }
.kv > span:last-child { min-width: 0; overflow-wrap: anywhere; }
code { overflow-wrap: anywhere; }

/* Long forms (request a gig, event, person, venue, festival…): the buttons stay in reach above the bottom nav.
 * The bar spans the card edge to edge, so it cancels the card's 16px padding. */
form.card--pad-lg > .form-actions:last-child {
  position: sticky; bottom: calc(var(--m-nav) + var(--m-safe)); z-index: 6;
  margin: 0 -16px -16px; padding: 12px 16px; background: var(--content1);
  border-top: 1px solid var(--divider); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: nowrap;
}
form.card--pad-lg > .form-actions:last-child .btn--primary { flex: 2 1 auto; order: 0; }

/* Empty date and time fields: iOS draws them blank, with no placeholder and no icon, and can shrink them.
 * Give them full height, left-aligned text, a calendar/clock icon and a hint while they are empty. */
input[type=date].input, input[type=time].input, input[type=datetime-local].input {
  -webkit-appearance: none; appearance: none; display: flex; align-items: center; min-height: 48px; text-align: left;
  padding-right: 44px; background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='3'/%3E%3Cpath d='M8 2v4M16 2v4M3 10h18'/%3E%3C/svg%3E");
}
input[type=time].input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
}
input[type=date].input::-webkit-date-and-time-value, input[type=time].input::-webkit-date-and-time-value { text-align: left; }
input[type=date].input::-webkit-calendar-picker-indicator, input[type=time].input::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer;
}
input[type=date].input, input[type=time].input { position: relative; }
/* The dd/mm/yyyy label (app.css) matches the 16px phone field text. */
.date-wrap.is-uk::after { font-size: 16px; }

/* ---------- Tabs, chips, segmented controls: one swipeable line ---------- */
.tabs { flex-wrap: nowrap; overflow-x: auto; gap: 20px; margin: 0 calc(-1 * var(--m-gutter)); padding: 0 var(--m-gutter);
  scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 13px 0 12px; }
.chip { line-height: 36px; padding: 0 14px; }
/* Touch targets: small pills and buttons keep their look but get a 44px tall hit area. */
.chip, .add-pill, .me-pill { position: relative; }
.chip::after, .add-pill::after, .me-pill::after { content: ""; position: absolute; inset: -7px 0; }
.chip::after { inset: -4px 0; }
.btn--sm::after, .btn--xs::after { content: ""; position: absolute; inset: -4px 0; }
.switch input { top: -10px; bottom: -10px; height: auto; }
.segmented label, .segmented a { padding: 13px 0; }
.add-pill { line-height: 24px; padding: 2px 12px; }
.me-pill { padding: 4px 4px 4px 12px; }
.me-pill__x { width: 24px; height: 24px; }
button.tick { width: 24px; height: 24px; border-radius: 7px; position: relative; }
button.tick::after { content: ""; position: absolute; inset: -10px; }

/* ---------- Settings: section strip on top, content full width ---------- */
.settings { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.settings__body { max-width: none; min-width: 0; }
.settings__nav {
  position: sticky; top: 0; z-index: 7; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px;
  margin: 0 calc(-1 * var(--m-gutter)); padding: 8px var(--m-gutter); background: var(--default-50);
  scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: var(--m-gutter);
}
.settings__nav::-webkit-scrollbar { display: none; }
.settings__tab { flex: none; white-space: nowrap; scroll-snap-align: start; padding: 0 14px; line-height: 38px;
  background: var(--content1); box-shadow: inset 0 0 0 1px var(--border-control); border-left: 0; }
.settings__tab.is-active { background: var(--text-dark); color: var(--mjb-gold); }
.settings__hint { display: none; }
.settings__body .card--pad > .form-actions:last-child { justify-content: stretch; }
/* Settings tables (PR templates, tokens, webhooks…): one block per row, buttons underneath. */
.settings__body .tbl:not(.tbl--stack), .settings__body .tbl:not(.tbl--stack) tbody { display: block; }
.settings__body .tbl:not(.tbl--stack) thead { display: none; }
.settings__body .tbl:not(.tbl--stack) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 8px;
  border-bottom: 1px solid var(--default-100); align-items: center; }
.settings__body .tbl:not(.tbl--stack) tr:last-child { border-bottom: 0; }
.settings__body .tbl:not(.tbl--stack) td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
.settings__body .tbl:not(.tbl--stack) td.actions { grid-column: 1 / -1; text-align: left; white-space: normal; display: flex; flex-wrap: wrap; gap: 8px; }
.settings__body .tbl:not(.tbl--stack) td.actions .inline-form { display: contents; }
.settings__body .tbl:not(.tbl--stack) td.actions .btn { flex: 1 1 auto; margin: 0; }
.settings__body .card--table { overflow-x: visible; }
.settings__body .row > .btn { flex: 1 1 auto; }

/* PR template editor */
.tpl-edit .form-actions { position: sticky; bottom: calc(var(--m-nav) + var(--m-safe)); z-index: 6; background: var(--content1);
  margin: 0 -16px -16px; padding: 12px 16px; border-top: 1px solid var(--divider); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.preview-frame--tall { min-height: 70vh; }

/* ---------- Stacked tables (one card per row) ----------
 * app.css makes each cell a flex row (label left, value right). That splits a cell with several bits of text into
 * narrow columns ("PR e m ail"), so on phones a cell is a plain block: the label floats left, the value flows right
 * and wraps normally. Cells that hold controls stay flex. Rows wrap so small cells can share a line. */
.tbl--stack tr { flex-flow: row wrap; column-gap: 16px; position: relative; }
.tbl--stack td { display: block; flex: 1 1 100%; text-align: right; min-width: 0; }
.tbl--stack td::before { float: left; margin-right: 12px; text-align: left; }
.tbl--stack td::after { content: ""; display: block; clear: both; }
.tbl--stack td > .row, .tbl--stack td > .scorebar { justify-content: flex-end; }
.tbl--stack td.actions, .tbl--stack td.empty, .tbl--stack td:has(form:not(.inline-form)) { display: flex; }
.tbl--stack td.actions::after, .tbl--stack td.empty::after, .tbl--stack td:has(form:not(.inline-form))::after { content: none; }
.tbl--stack td code { white-space: normal; }
.tbl--stack .badge { white-space: normal; }
/* A title cell whose link carries the class (To request, Collaborators) is the card title too. */
.tbl--stack td:has(> a.cell-strong), .tbl--stack td:has(.name-link) { order: -1; text-align: left; font-size: 15px; padding-right: 36px; }
.tbl--stack td:has(> a.cell-strong)::before, .tbl--stack td:has(.name-link)::before { content: none; }
.tbl--stack td:has(> a.cell-strong) > .muted { display: block; }
.tbl--stack td:has(.name-link) > .row { justify-content: flex-start; }
.tbl--stack td.cell-strong { padding-right: 36px; }
/* Row checkbox for bulk actions: top-right corner of the card instead of a line of its own. */
.tbl--stack td.pick { position: absolute; top: 12px; right: 0; width: auto; flex: none; }
.tbl--stack td.pick::after { content: none; }
.tbl--stack input[type=checkbox], .pick-row input[type=checkbox], .pick-row input[type=radio], .pick-simple input, .card__head > input[type=checkbox] {
  width: 22px; height: 22px; }
/* Small cells that share a line: Approve/Reject on festival requests, the numbers on PR contacts. */
.tbl--stack td.cell-half { flex: 1 1 calc(50% - 8px); display: flex; justify-content: space-between; align-items: center; }
.tbl--stack td.cell-half::after { content: none; }
.tbl--stack td.cell-num { flex: 1 1 calc(25% - 12px); text-align: left; font-size: 15px; font-weight: 600; }
.tbl--stack td.cell-num::before { float: none; display: block; font-size: 11px; font-weight: 400; margin: 0 0 2px; max-width: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Switch forms (Active) sit on the right of their label, like the other values. */
.tbl--stack td:has(> form[data-autosubmit] .switch) { flex-direction: row; justify-content: space-between; align-items: center; }
.tbl--stack td.actions .btn, .tbl--stack td.actions summary.btn { min-height: 40px; }
.tbl--stack td.actions > .inline-form, .tbl--stack td.actions > .btn, .tbl--stack td.actions > details { flex: 1 1 auto; }
.tbl--stack td.actions > .inline-form { display: flex; flex-wrap: wrap; gap: 8px; }
.tbl--stack td.actions > .inline-form > .btn { flex: 1 1 auto; }
.tbl--stack td.actions details > summary.btn { width: 100%; }
.tbl--stack .deliver-form { flex-wrap: wrap; width: 100%; }
.tbl--stack .deliver-form .input { flex: 1 1 100%; width: 100%; height: 44px; }
.tbl--stack .deliver-form .btn { flex: 1 1 100%; height: 40px; }
.tbl--stack td:has(> .deliver-form)::before { content: none; }

/* Tables that keep their columns: scroll sideways instead of breaking every word. */
.card--table > .tbl:not(.tbl--stack) th, .card--table > .tbl:not(.tbl--stack) td,
.table-scroll > .tbl th, .table-scroll > .tbl td { white-space: nowrap; }
.table-scroll > .tbl { min-width: 560px; }
.badge { white-space: nowrap; }

/* Approval and event People lists: name next to the tick, the eligibility badge on the right.
 * (The hidden bulk input on Approval would otherwise push the name into the badge's column.) */
.pick-row > input[type=checkbox], .pick-row > input[type=radio] { grid-column: 1; grid-row: 1; }
.pick-row > .medium { grid-column: 2; grid-row: 1; min-width: 0; overflow-wrap: anywhere; }
.pick-row > .medium + span { grid-column: 3; grid-row: 1; }
.approval-waiting { order: 3; width: 100%; }

/* Banners with buttons: text on top, buttons underneath. */
.alert--row { flex-direction: column; align-items: stretch; }
.alert--row .row .btn, .alert--row > .btn { flex: 1 1 auto; }
.alert--default .btn:not(.btn--primary) { background: var(--content1); }

/* Description lists keep two columns (they collapse to one at 480px in app.css). */
.dl { margin: 0; grid-template-columns: 104px minmax(0, 1fr); gap: 6px 12px; }
.dl dd { margin-bottom: 0; }

/* Dashboard */
.card .grid-2:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv > span:first-child { white-space: nowrap; }

/* Filter chips: the "·" separators only make sense on one line. */
.chips > .muted { display: none; }

/* To-do board: swipe between columns instead of one very long list. */
.board { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 86%; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * var(--m-gutter)); padding: 0 var(--m-gutter) 8px; scroll-padding: 0 var(--m-gutter); scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.board__col { scroll-snap-align: start; }
.board__card .row .btn { flex: 1 1 auto; }

/* Duplicates: name on the left, details on the right. */
.pick-simple > span:first-of-type { flex: 1; min-width: 0; }

/* ---------- Events list cards ---------- */
.m-card { padding: 14px 16px; gap: 6px; }
.m-card > .row:first-child { flex-wrap: nowrap; align-items: flex-start; }
.m-card > .row:first-child > a.strong { font-size: 15px; line-height: 20px; min-width: 0; }
.m-slots { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.m-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-height: 22px; }
.m-slot__label { color: var(--default-500); width: 52px; flex-shrink: 0; }
.m-sep { display: none; }
.m-card .row--between.tiny { flex-wrap: nowrap; align-items: flex-end; }
.m-card .row--between.tiny > .badge { flex-shrink: 0; }

/* ---------- Request a gig: title, the request window and venue hint, then the form ---------- */
#request-check:not(:has(*)) { display: none; }
.request-layout { gap: 12px; }
.request-layout > .stack:first-child { display: contents; }
.request-layout > .stack:first-child > form { order: 2; }
.request-tips { order: 1; margin-top: 0; }
.request-tips > .card { padding: 12px 14px; gap: 4px; background: var(--primary-50); box-shadow: none; }
.request-tips .card__title { font-size: 13px; }

/* ---------- Event page (admin): people, then status and comments, then the long details form ---------- */
.event-admin { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
.event-admin > .stack { display: contents; }
.event-admin > .stack:first-child > :first-child { order: -3; }
.event-admin > .stack:last-child > * { order: -2; }
.event-admin > .stack:last-child > form[action*="/delete/"] { order: 1; }
.textarea[rows="10"], textarea.textarea:not([rows]) { height: 112px; }

/* ---------- Guidelines: the article first, the menu one tap away ---------- */
.page--flush .mobile-bar { margin: 0; padding: 8px var(--m-gutter); }
.guide { flex-direction: column; }
.guide__main { order: -1; padding: 12px var(--m-gutter) 24px; gap: 14px; }
.guide__title { font-size: 24px; line-height: 30px; }
.guide__nav { border-top: 1px solid var(--divider); border-bottom: 0; padding: 20px var(--m-gutter); scroll-margin-top: 8px; }
.guide__link { padding: 10px 10px; font-size: 14px; }
.guide__jump { display: inline-flex; }
.prose { font-size: 16px; line-height: 25px; }
.prose table { display: block; overflow-x: auto; max-width: 100%; }
.messages { left: var(--m-gutter); right: var(--m-gutter); top: 12px; width: auto; max-width: none; }

/* ---------- Calendar: dots in the month grid, the month's events listed underneath ---------- */
.cal { gap: 2px; padding: 6px; }
.cal__wd { padding: 6px 0; text-align: center; font-size: 11px; }
.cal__day { min-height: 48px; padding: 4px 2px; align-items: center; flex-direction: row; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 3px; }
.cal__n { width: 100%; text-align: center; }
.cal__ev { width: 6px; height: 6px; padding: 0; border-radius: 9999px; font-size: 0; line-height: 0; background: var(--success-500); }
.cal__ev--mine { background: var(--text-dark); }
.cal-list { display: flex; flex-direction: column; }
.page-actions > .segmented { flex: 1; width: auto; }
.page-actions > .btn--md { min-width: 44px; height: 40px; }

/* ---------- Login ---------- */
.login-card { padding: 0 20px 24px; }
.logo-band { margin: 0 -20px; padding: 20px 20px 16px; }
.center-screen { padding: 16px; }

/* Last: empty cells stay hidden even where a rule above turns a cell back into flex. */
.tbl--stack td:empty { display: none; }
.cal-list:not(:has(a)) { display: none; }
.cal-list__ev { color: var(--foreground); flex-wrap: nowrap; }
.cal-list__ev:hover { text-decoration: none; color: var(--foreground); }
.tbl--stack td .nowrap { white-space: nowrap; }
.tbl--stack td > a.cell-strong { color: var(--foreground); font-weight: 600; }
/* Action cells keep their buttons side by side, even when they are separate forms. */
.tbl--stack td.actions:has(form) { flex-direction: row; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.tbl--stack td.actions > form { flex: 1 1 0; min-width: max-content; display: flex; }
.tbl--stack td.actions > form:not(.inline-form) > .btn, .tbl--stack td.actions > form > .btn:only-of-type { flex: 1 1 auto; }
