/* Weekly availability: the editor grid, the read-only week on profiles, and the list of
   shared windows. Every rule uses an avail- class and the theme variables from app.css. */

/* ---------------------------------------------------------------- editor */
.avail-zone { margin: 0; }
.avail-form h2 { margin-bottom: 10px; }
.avail-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.avail-quick button { min-height: 44px; }
.avail-js-only { display: none; }
.avail-js .avail-js-only { display: block; }
.avail-js .avail-nojs { display: none; }
.avail-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin: 16px 0 6px; }
.avail-tools button { min-height: 44px; }

.avail-grid { table-layout: fixed; border-collapse: separate; border-spacing: 3px 0; width: 100%; margin: 0; font-size: .8rem; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.avail-grid th, .avail-grid td { padding: 0; border: 0; vertical-align: top; }
.avail-grid thead td, .avail-grid tbody th { width: 46px; }
.avail-grid thead th, .avail-grid thead td {
  position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 5;
  background: var(--panel); color: var(--text); text-align: center; font-weight: 700; font-size: .85rem;
  padding: 8px 0; border-bottom: var(--line-width) solid var(--line);
}
.avail-grid abbr { text-decoration: none; cursor: default; }
.avail-grid tbody th { position: relative; text-align: right; font-weight: 500; color: var(--muted); white-space: nowrap; }
.avail-time { position: absolute; right: 6px; top: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.avail-grid tr.avail-hour td { padding-top: 5px; }
.avail-grid tr.avail-half td { padding-top: 2px; }
.avail-grid tr.avail-hour th .avail-time { top: 5px; }
.avail-hide-early .avail-early { display: none; }

.avail-cell { display: block; position: relative; height: 44px; margin: 0; cursor: pointer; }
.avail-cell input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.avail-cell span {
  position: absolute; inset: 0; border-radius: 6px; background: var(--panel-2);
  border: 1px solid var(--muted);
}
.avail-hour .avail-cell span { border-radius: 6px 6px 2px 2px; }
.avail-half .avail-cell span { border-radius: 2px 2px 6px 6px; }
/* marked: filled with the accent color and a tick, so it never depends on color alone */
.avail-cell input:checked + span { background: var(--accent); border-color: var(--accent); }
.avail-cell input:checked + span::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 11px; margin: -8px 0 0 -4px;
  border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.avail-cell input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; box-shadow: 0 0 0 1px var(--panel), inset 0 0 0 2px var(--panel); z-index: 2; }
.avail-cell:hover span { border-color: var(--muted); }
.avail-painting, .avail-painting * { cursor: cell; }

.avail-save {
  position: sticky; bottom: 0; z-index: 6; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  margin: 16px -20px -20px; padding: 12px 20px; background: var(--panel);
  border-top: var(--line-width) solid var(--line); border-radius: 0 0 calc(var(--radius) + 2px) calc(var(--radius) + 2px);
}
.avail-status { color: var(--warn-text); font-weight: 600; }
.avail-status:empty { display: none; }

/* a mouse can hit smaller rows, so the whole evening fits on one screen */
@media (hover: hover) and (pointer: fine) and (min-width: 761px) {
  .avail-cell { height: 26px; }
  .avail-cell input:checked + span::after { height: 9px; width: 5px; margin: -7px 0 0 -3px; }
  .avail-grid tr.avail-hour td { padding-top: 4px; }
  .avail-grid tr.avail-half td { padding-top: 1px; }
}
@media (max-width: 760px) {
  .avail-grid thead th, .avail-grid thead td { top: calc(60px + env(safe-area-inset-top)); }
  .avail-save { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  /* seven 44px columns have to fit a 390px phone: the card runs almost edge to edge */
  .avail-form { margin-left: -10px; margin-right: -10px; padding-left: 4px; padding-right: 4px; }
  .avail-form > h2, .avail-form > .avail-quick, .avail-form > .hint, .avail-form > .avail-tools { margin-left: 12px; margin-right: 12px; }
  .avail-grid { border-spacing: 2px 0; font-size: .68rem; }
  .avail-grid thead td, .avail-grid tbody th { width: 32px; }
  .avail-time { right: 2px; }
  .avail-save { margin: 16px -4px -16px; padding: 10px 16px; }
  .avail-save button { flex: 1 1 auto; }
}

/* ---------------------------------------------------------------- shared windows list */
.avail-windows { list-style: none; margin: 0; padding: 0; }
.avail-window { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; padding: 10px 0; min-height: 52px; }
.avail-window + .avail-window { border-top: var(--line-width) solid var(--line); }
.avail-window-when { display: flex; flex-direction: column; min-width: 0; }
.avail-window-when strong { font-family: var(--font-head); font-size: 1.05rem; }
.avail-window-who { display: flex; align-items: center; gap: 10px; }
.avail-window-count { font-weight: 600; font-size: .9rem; color: var(--good-text); background: var(--good-bg); border: var(--line-width) solid var(--good-line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.avail-faces { display: inline-flex; align-items: center; }
.avail-faces a { display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }
.avail-faces a + a, .avail-faces a + .avail-faces-more { margin-left: -8px; }
.avail-faces a:hover, .avail-faces a:focus-visible { position: relative; z-index: 1; box-shadow: 0 0 0 2px var(--accent); }
.avail-faces-more { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 16px; background: var(--panel-2); color: var(--text); font-size: .75rem; font-weight: 700; box-shadow: 0 0 0 2px var(--panel); }

/* "Plan with..." picker on the Friends page */
.avail-plan { margin-top: 14px; border-top: var(--line-width) solid var(--line); padding-top: 6px; }
.avail-plan summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--link); }
.avail-plan summary::-webkit-details-marker { display: none; }
.avail-plan summary::before { content: ""; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); flex: none; margin-right: 2px; }
.avail-plan[open] summary::before { transform: rotate(45deg); }
.avail-plan summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.avail-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.avail-pick label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 6px 10px; min-height: 48px; border: var(--line-width) solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: .95rem; font-weight: 600; cursor: pointer; min-width: 0; }
.avail-pick label span.avail-pick-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.avail-pick input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.avail-pick label:has(input:checked) { border-color: var(--pick-on-line); background: var(--pick-on-bg); }
.avail-pick label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.avail-note { margin: 10px 0 0; }

/* ---------------------------------------------------------------- read-only week (profiles) */
.avail-mini { max-width: 460px; }
.avail-mini-head, .avail-mini-body { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); column-gap: 3px; }
.avail-mini-head span { text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.avail-mini-time { height: 7px; position: relative; font-size: .68rem; color: var(--muted); text-align: right; padding-right: 6px; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.avail-mini-time.avail-mini-hour { margin-top: 1px; }
.avail-mini-cell { height: 7px; background: var(--panel-2); }
.avail-mini-cell.avail-mini-hour { margin-top: 1px; box-shadow: 0 -1px 0 var(--line); }
.avail-mini-cell.avail-mini-on { background: var(--accent); box-shadow: none; }
.avail-mini-text { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; font-size: .9rem; color: var(--muted); }
.avail-mini-text li { display: grid; grid-template-columns: 6.2em minmax(0, 1fr); gap: 8px; }
.avail-mini-text strong { color: var(--text); }
