/* Element-level styling: the reset, page frame, typography, and the bare
   look of tables, inputs and buttons. No component classes live here --
   those are components.css.

   The one exception is .section-title. It is a class, but it is page-frame
   furniture rather than a reusable component, and splitting it from the
   section rules it belongs to would make both files harder to read. */

* {
  box-sizing: border-box;
}

/* 捲軸的位置永遠保留：短頁沒有捲軸、長頁有，換頁時整個版面（連同側欄）會左右跳
   15px（彩排 2 側欄 #4）。候診區電視畫面不捲動，在 views.css 取消保留。 */
html {
  scrollbar-gutter: stable;
}

/* The page frame is the shell's job (see views.css): body only carries the
   things that are true everywhere. */
body {
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  background: var(--canvas);
  color: var(--ink);
  margin: 0;
  line-height: var(--lh-text);
  /* Lining figures: the display serif's default old-style digits would
     make a date read like lower-case text. */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-family: var(--font-display);
  font-size: var(--fs-large);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin: 0 0 var(--sp-1);
}

section + section {
  margin-top: var(--sp-8);
}

section > h2.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-large);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  line-height: 1.15;
  /* 標題到內容 20px，跟手機版同一個節奏（使用者回報「留白太多」，2026-10-23）。 */
  margin: 0 0 var(--sp-5);
}

a {
  color: var(--ink-2);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:hover {
  color: var(--ink);
}

/* One focus mark for everything a keyboard can reach. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* --- Tables ----------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
}

th {
  text-align: left;
  font-size: var(--fs-footnote);
  font-weight: var(--fw-regular);
  color: var(--ink-3);
  padding: 0 var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--hairline-strong);
  white-space: nowrap;
}

/* The first column (a name, a date, a time) stays on one line rather than
   stacking a character per line when a table is short of room. */
td:first-child {
  white-space: nowrap;
}

td {
  padding: var(--sp-3) var(--sp-4);
  height: var(--h-row);
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--nav-hover);
}

tr.is-clickable:focus-visible {
  outline-offset: -2px;
}

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

input,
select,
textarea {
  min-height: var(--h-control);
  padding: 0 var(--sp-4);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-input);
  font-size: var(--fs-body);
  font-family: inherit;
  color: var(--ink);
  background: var(--group);
}

/* Inside a card the field takes the page's colour, or it would vanish. */
.card input,
.card select,
.card textarea {
  background: var(--canvas);
}

input[type="checkbox"],
input[type="radio"] {
  min-height: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--ink);
}

input[type="file"] {
  padding: var(--sp-2) var(--sp-4);
  height: auto;
}

input[type="file"]::file-selector-button {
  margin-right: var(--sp-3);
  padding: var(--sp-1) var(--sp-4);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-footnote);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

textarea {
  min-height: 96px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
  line-height: var(--lh-text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink-2);
}

input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
}

/* Buttons: the bare element is the secondary look -- fill, ink, a pill.
   Roles (primary, danger, plain) are classes in components.css. Only
   colour and the press scale animate; nothing moves. */
button {
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  min-height: var(--h-control);
  padding: 0 var(--sp-5);
  border-radius: var(--r-pill);
  border: 0;
  background: var(--fill);
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-micro),
    color var(--dur-micro) var(--ease-micro),
    transform var(--dur-press) var(--ease-micro);
}

button:hover {
  background: var(--fill-strong);
}

button:active:not(:disabled) {
  background: var(--fill-press);
  transform: scale(var(--press-scale));
}

button:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-ink);
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }

  button:active:not(:disabled) {
    transform: none;
  }
}
