/*
 * The only stylesheet of the site. It is copied to assets/site.css as it is;
 * there is no build step. Colors and sizes follow design A with palette 9.
 */

:root {
  --white: #FFFFFF;
  --stone-50: #FAFAF9;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --orange-50: #FFF1E6;
  --orange-500: #FF6B00;
  --orange-700: #C24E00;
  --orange-800: #9A3B00;
  --orange-950: #2B1400;
  /* The border of the selector fields, about 3.2:1 against white */
  --input-border: #8B919B;
  --font-sans: 'Noto Sans TC', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --card-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--stone-50);
  color: var(--gray-900);
  font-family: var(--font-sans);
}

a {
  color: var(--orange-700);
}

a:hover {
  color: var(--orange-800);
}

.mono {
  font-family: var(--font-mono);
}

/* Content for pages with and without JavaScript. The script in the <head>
   of every page replaces the no-js class of <html> with js when the browser
   supports ES modules. It restores no-js if the site module fails to load,
   so a page without the module shows its static content and links. */

.no-js .js-only {
  display: none;
}

.js .no-js-only {
  display: none;
}

/* Text for screen readers only, such as the 已複製 announcement */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Header */

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.site-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand,
.brand:hover {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gray-900);
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--orange-500);
  color: var(--orange-950);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 15px;
}

.site-nav a,
.site-nav a:hover {
  color: var(--gray-700);
  text-decoration: none;
}

/* Main content and the heading block */

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 64px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.heading {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.heading h1,
.heading .page-title {
  margin: 0;
  font-size: 32px;
  line-height: 1.3;
  font-weight: 700;
}

.lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-600);
}

/* The selector card between the heading block and the result card: the
   bank field and the branch field, each with the option list it opens */

.selector-card {
  padding: 24px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: var(--white);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.selector-field {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selector-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
}

/* Holds a field, its arrow and its option list */
.selector-control {
  position: relative;
}

.selector-input {
  width: 100%;
  height: 52px;
  margin: 0;
  padding: 0 48px 0 16px;
  box-sizing: border-box;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--white);
  color: var(--gray-900);
  font: inherit;
  font-size: 16px;
}

.selector-input:focus {
  outline: 2px solid var(--orange-700);
  outline-offset: 2px;
}

.selector-input:disabled {
  border-color: var(--gray-300);
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}

.selector-arrow {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--gray-600);
  pointer-events: none;
}

.selector-help {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-500);
}

/* The option list opens 4px below its field, as wide as the field, over
   the content below it */
.selector-listbox {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
}

.selector-listbox[hidden] {
  display: none;
}

.selector-option {
  min-height: 44px;
  padding: 12px 16px;
  box-sizing: border-box;
  font-size: 15px;
  color: var(--gray-900);
  overflow-wrap: anywhere;
  cursor: pointer;
}

.selector-option-code {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--gray-600);
}

.selector-option-institution {
  color: var(--gray-500);
}

/* The active option, the one that aria-activedescendant names */
.selector-option[aria-selected="true"] {
  background: var(--orange-50);
  color: var(--orange-950);
}

.selector-option[aria-selected="true"] .selector-option-code {
  color: var(--orange-800);
}

@media (forced-colors: active) {
  .selector-option[aria-selected="true"] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

/* The row that says nothing matched or the options did not load */
.selector-message {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--gray-500);
}

/* Cards: the result card of branch and institution pages, and the cards of
   the home and not-found pages */

.card {
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: var(--white);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.card-body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card-link {
  font-size: 18px;
  font-weight: 700;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-institution {
  align-self: flex-start;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--orange-700);
  text-decoration: none;
}

.result-institution:hover {
  color: var(--orange-800);
  text-decoration: underline;
}

.result-name {
  margin: 0;
  font-size: 26px;
  line-height: 1.3;
  font-weight: 700;
}

.bank-code-tag {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gray-100);
  font-size: 14px;
  color: var(--gray-700);
}

.bank-code-tag .mono {
  font-weight: 600;
  color: var(--gray-900);
}

/* The code box: the 7-digit code on branch pages, the 3-digit code on
   institution pages */

.code-box {
  padding: 20px 24px;
  border-radius: 14px;
  background: var(--orange-50);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.code-box-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.code-box-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--orange-800);
}

.code-box-code {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 44px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--orange-950);
}

.code-bank {
  color: var(--orange-700);
}

/* Separates the branch part from the bank part without inserting a
   character, so that copying the code gives the seven digits only. */
.code-branch {
  margin-left: 0.35em;
}

.code-box-note {
  margin: 0;
  font-size: 13px;
  color: var(--orange-800);
}

/* The copy buttons: 複製代碼 on institution pages, and 複製 4 碼 and 複製 7 碼
   on branch pages, to the right of the code and below it once the box
   wraps; 複製此頁連結 at the left of the action row */

/* Keeps a page's copy code buttons together, side by side, one above the
   other when they do not fit in one row */
.copy-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-code {
  flex-shrink: 0;
  height: 52px;
  margin: 0;
  padding: 0 24px;
  box-sizing: border-box;
  border: 0;
  border-radius: 12px;
  background: var(--orange-500);
  color: var(--orange-950);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.copy-link {
  height: 44px;
  margin: 0;
  padding: 0 16px;
  box-sizing: border-box;
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  background: var(--white);
  color: var(--gray-900);
  font: inherit;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* When the browser refuses the copy: the instruction under the code, and
   the page URL with the instruction under the action row's buttons */

.copy-hint {
  margin: 0;
  font-size: 13px;
  color: var(--orange-800);
}

.copy-fallback {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.copy-url {
  margin: 0;
  font-size: 14px;
  color: var(--gray-900);
  overflow-wrap: anywhere;
}

/* Address */

.address {
  margin: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 24px;
  row-gap: 14px;
  font-size: 16px;
  line-height: 1.6;
}

.address dt {
  color: var(--gray-500);
}

.address dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}

.address-missing {
  color: var(--gray-500);
}

.map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 500;
}

.branch-total {
  margin: 0;
  font-size: 15px;
  color: var(--gray-600);
}

/* The action row at the bottom of the result card */

.card-actions {
  padding: 16px 28px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.restart,
.restart:hover {
  margin-left: auto;
  height: 44px;
  padding: 0 16px;
  box-sizing: border-box;
  border-radius: 10px;
  background: transparent;
  color: var(--gray-700);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

/* Lists: the institution list and the branch list of an institution page */

.list-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-heading {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.list-heading-count {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--gray-500);
}

.list-card {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: var(--white);
  overflow: hidden;
}

.list-card li + li {
  border-top: 1px solid var(--gray-200);
}

.list-row {
  min-height: 52px;
  padding: 12px 20px;
  box-sizing: border-box;
  color: var(--gray-900);
  text-decoration: none;
}

.list-row:hover {
  color: var(--gray-900);
  background: var(--gray-50);
}

.list-row:hover .row-name {
  color: var(--orange-800);
}

.list-row:focus-visible {
  outline: 2px solid var(--orange-700);
  outline-offset: -2px;
}

.row-code {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
}

.row-name {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.row-count {
  font-size: 14px;
  color: var(--gray-500);
  white-space: nowrap;
}

.row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-institution {
  font-size: 13px;
  color: var(--gray-500);
}

.list-empty {
  margin: 0;
  padding: 16px 20px;
  color: var(--gray-500);
}

/* Institution list rows: code, name, number of branches */
.bank-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
}

/* Branch rows of an institution page: name, then the 7-digit code */
.branch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.branch-row .row-name {
  font-weight: 500;
}

/* Footer */

.site-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}

.site-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-600);
}

.site-footer p {
  margin: 0;
}

/* Phone widths: the number of branches moves below the name */

@media (max-width: 600px) {
  .bank-row {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 2px;
  }

  .bank-row .row-count {
    grid-column: 2;
  }
}
