/* ═══════════════════════════════════════════════════════════
   Chinese Characters — Ink Painting (水墨) Design System
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
  --ink:        #1A1410;
  --charcoal:   #4A3F35;
  --faded-ink:  #8C7B6B;
  --paper:      #F5F0E8;
  --paper-dark: #EDE7D9;
  --surface:    #FAF7F2;
  --seal-red:   #C0392B;
  --seal-light: #E74C3C;
}

/* ── Page Behaviour ───────────────────────────────────────── */
body {
  max-width: 400px;
  margin: 0 auto;
  overscroll-behavior-y: contain;
  background: var(--paper);
  font-family: 'ZCOOL QingKe HuangYou', serif;
  color: var(--ink);
  /* Subtle ink-wash radial gradient */
  background-image:
    radial-gradient(ellipse 60% 40% at 30% 20%, rgba(139,110,80,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 75% 70%, rgba(26,20,16,0.04) 0%, transparent 70%);
  background-attachment: fixed;
}

/* ── Typography ───────────────────────────────────────────── */
.hyphenate {
  hyphens: auto;
}

/* Global minimum size for helper/hint text */
.form-text,
.field-hint,
small,
.small {
  font-family: system-ui, sans-serif;
  font-size: 16px !important;
  color: var(--faded-ink);
  line-height: 1.5;
}

/* ── Content wrapper ──────────────────────────────────────── */
#content {
  padding-bottom: 100px;
}

/* Auth pages have no navbar — cancel the bottom padding */
#content:has(.auth-page-wrap) {
  padding-bottom: 0;
}

/* ── Page / Section Titles ────────────────────────────────── */
.page-title,
h1.page-title,
.container > h1 {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 22px;
  color: var(--ink);
  padding: 14px 0 10px;
  border-bottom: 2px solid var(--seal-red);
  margin-bottom: 24px;
  letter-spacing: 0.02em;
}

/* Form pages override: tighter bottom margin, no top padding */
.container h1 {
  padding-bottom: 10px;
  padding-top: 0;
  margin-bottom: 0;
}

/* ── Seal-stamp remaining pill ────────────────────────────── */
.seal-pill,
.badge.rounded-pill.bg-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--seal-red) !important;
  color: var(--surface) !important;
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 20px !important;
  letter-spacing: 0.03em;
  padding: 3px 14px !important;
  border-radius: 2px !important;
  box-shadow: 1px 1px 0 rgba(26,20,16,0.3), -1px -1px 0 rgba(255,255,255,0.15) inset;
}

/* ── Quiz character display ───────────────────────────────── */
#quizCharacters {
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 12px 20px 8px;
  font-size: 96px;
  line-height: 1;
  font-family: 'KaiTi', serif;
  font-weight: normal;
  color: var(--ink);
  text-align: center;
  text-shadow:
    0 1px 3px rgba(26,20,16,0.18),
    1px 1px 0   rgba(26,20,16,0.06);
  letter-spacing: -0.02em;
  user-select: none;
}

/* ── Quiz pinyin ──────────────────────────────────────────── */
#quizPinyin {
  font-size: 36px;
  font-family: 'Noto Serif', serif;
  color: var(--charcoal);
  text-align: center;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* ── Answer card (scrollable area) ───────────────────────── */
.quiz-answer-card {
  background: var(--surface);
  padding: 18px 20px 16px;
  border: 1.5px solid rgba(26,20,16,0.20);
  box-shadow: 3px 4px 14px rgba(26,20,16,0.10), inset 0 1px 0 rgba(255,255,255,0.65);
  margin: 0 0 24px;
}

/* ── Hide-scroll translation list ────────────────────────── */
.hide-scroll {
  height: 180px;
  overflow: scroll;
  -webkit-overflow-scrolling: touch;
  font-size: 1.2em;
}

.hide-scroll::-webkit-scrollbar { width: 3px; }
.hide-scroll::-webkit-scrollbar-track { background: transparent; }
.hide-scroll::-webkit-scrollbar-thumb {
  background: rgba(26,20,16,0.2);
  border-radius: 2px;
}

.hide-scroll > div {
  padding-top: 180px;
  min-height: 360px;
}

/* Translation list items */
#quizTranslation .list-group-item {
  font-family: 'Noto Serif', serif;
  font-size: 18px;
  color: var(--charcoal);
  text-align: center;
  padding: 5px 0;
  border: none;
  border-bottom: 1px solid rgba(26,20,16,0.08);
  background: transparent;
  letter-spacing: 0.02em;
}

#quizTranslation .list-group-item:last-child {
  border-bottom: none;
}

/* ── Brush-stroke SVG divider ─────────────────────────────── */
.brush-divider {
  display: block;
  width: 100%;
  height: 10px;
  margin: 4px 0 10px;
  overflow: visible;
}

/* ── Rating buttons (brush-circle SVG style) ─────────────── */
.btn-ink-circle {
  width: 92px;
  height: 92px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease;
}

.btn-ink-circle:active { transform: scale(0.93); }

.btn-ink-circle svg.brush-circle {
  width: 92px;
  height: 92px;
  overflow: visible;
}

/* Good (✓) button: seal-red */
.btn-good .circle-fill   { fill: rgba(192,57,43,0.08); }
.btn-good .circle-stroke { stroke: var(--seal-red); }
.btn-good .icon-mark     { stroke: var(--seal-red); }

/* Again (✗) button: charcoal */
.btn-again .circle-fill   { fill: rgba(26,20,16,0.05); }
.btn-again .circle-stroke { stroke: var(--charcoal); }
.btn-again .icon-mark     { stroke: var(--charcoal); }

/* Rating buttons row */
.rating-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 16px 32px 28px;
}

/* ── Bottom navigation bar — colour only, layout left to Bootstrap ── */

/* Disabled buttons */
#menu .btn:disabled {
  border: none;
  opacity: 0.25;
}

/* Nav bar background and border */
#menu .navbar {
  background: var(--surface) !important;
  border: 1px solid rgba(26,20,16,0.18) !important;
  box-shadow: 0 -1px 8px rgba(26,20,16,0.07), 2px 2px 6px rgba(26,20,16,0.06) !important;
}

#menu .navbar .btn {
  color: var(--charcoal) !important;
  -webkit-tap-highlight-color: transparent;
}

#menu .navbar .btn:active { color: var(--seal-red) !important; }

/* Menu (hamburger) panel — same chrome as navbar */
#menu .col-4 > div {
  background: var(--surface) !important;
  border: 1px solid rgba(26,20,16,0.18) !important;
  box-shadow: 0 -1px 8px rgba(26,20,16,0.07), 2px 2px 6px rgba(26,20,16,0.06) !important;
}

#menu .col-4 .btn {
  color: var(--charcoal);
  -webkit-tap-highlight-color: transparent;
}

#menu .col-4 .btn:active { background: var(--paper-dark) !important; }

/* ── Offcanvas menu ───────────────────────────────────────── */
.offcanvas {
  max-width: 70%;
  background: var(--surface) !important;
  border-left: 1.5px solid rgba(26,20,16,0.15) !important;
}

.offcanvas-header {
  border-bottom: none !important;
  padding: 20px 20px 12px;
}

.offcanvas-title {
  font-family: 'ZCOOL QingKe HuangYou', serif !important;
  font-size: 24px !important;
  color: var(--ink) !important;
  border-bottom: 2px solid var(--seal-red);
  padding-bottom: 2px;
}

/* Offcanvas section labels */
.offcanvas .col-form-label,
.offcanvas .col-12.fs-6.fw-medium,
.offcanvas .col-10.col-form-label {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px !important;
  color: var(--charcoal);
  letter-spacing: 0.03em;
}

/* Offcanvas range slider */
.offcanvas input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(26,20,16,0.2);
  border-radius: 2px;
  outline: none;
}

.offcanvas input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--seal-red);
  border-radius: 50%;
  cursor: pointer;
}

/* Offcanvas number input */
.offcanvas .form-control {
  background: var(--paper);
  border: 1px solid rgba(26,20,16,0.25);
  border-radius: 2px;
  padding: 6px 10px;
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 16px;
  color: var(--ink);
}

.offcanvas .form-control:focus {
  outline: none;
  border-color: var(--seal-red);
  box-shadow: 0 0 0 2px rgba(192,57,43,0.12);
}

/* Radio buttons and toggle switches */
.form-check-input {
  accent-color: var(--seal-red);
}

.form-check-input:checked {
  background-color: var(--seal-red);
  border-color: var(--seal-red);
}

/* Offcanvas hr */
.offcanvas hr {
  border: none;
  border-top: 1px solid rgba(26,20,16,0.12);
  margin: 14px 0;
}

/* Passkey list rows */
.offcanvas #passkeyList .d-flex {
  padding: 7px 0;
  border-bottom: 1px dashed rgba(26,20,16,0.12);
  font-family: 'Noto Serif', serif;
  font-size: 16px;
  color: var(--charcoal);
}

/* Passkey delete buttons */
.offcanvas .btn-link.text-danger,
.offcanvas .delete-passkey-btn {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  color: var(--seal-red) !important;
  padding: 0;
  text-decoration: none;
}

/* ── Offcanvas action buttons — shared base ───────────────── */
/* Add Passkey, Sign Out, and Delete Account buttons share layout */
#addPasskeyBtn,
.offcanvas .btn-outline-secondary,
.offcanvas .btn-outline-danger,
.offcanvas .btn-danger {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  padding: 6px 12px;
  width: 100%;
  cursor: pointer;
  letter-spacing: 0.03em;
  border-radius: 0;
}

/* Add Passkey button */
#addPasskeyBtn,
.offcanvas .btn-outline-secondary {
  background: transparent;
  border: 1.5px solid rgba(26,20,16,0.3);
  color: var(--charcoal);
}

#addPasskeyBtn:hover,
.offcanvas .btn-outline-secondary:hover {
  background: var(--paper-dark);
  color: var(--ink);
}

/* Sign Out and Delete Account buttons */
.offcanvas .btn-outline-danger,
.offcanvas .btn-danger {
  background: transparent;
  border: 1.5px solid var(--seal-red);
  color: var(--seal-red);
}

.offcanvas .btn-outline-danger:hover,
.offcanvas .btn-danger:hover {
  background: rgba(192,57,43,0.06);
  color: var(--seal-red);
}

/* Delete Account button only — suppress Bootstrap's box-shadow */
.offcanvas .btn-danger {
  box-shadow: none;
}

/* Save Changes button */
#optionSave,
.offcanvas .btn-primary {
  background: var(--seal-red) !important;
  color: var(--surface) !important;
  border: none !important;
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  letter-spacing: 0.05em;
  padding: 8px 28px;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(26,20,16,0.3) !important;
  transition: transform 0.1s;
  border-radius: 0 !important;
}

#optionSave:active,
.offcanvas .btn-primary:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(26,20,16,0.3) !important;
}

#optionSave:disabled,
.offcanvas .btn-primary:disabled {
  opacity: 0.45;
  box-shadow: 2px 2px 0 rgba(26,20,16,0.15) !important;
}

/* Version note */
#optionVersion {
  font-family: system-ui, sans-serif;
  font-size: 13px !important;
  color: var(--faded-ink);
  font-style: italic;
}

/* ── Delete Account modal ─────────────────────────────────── */
.modal-content {
  background: var(--surface);
  border: 1.5px solid rgba(26,20,16,0.20);
  border-radius: 2px;
}

.modal-title {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 20px;
  color: var(--ink);
}

.modal-body {
  font-family: 'Noto Serif', serif;
  font-size: 16px;
  color: var(--charcoal);
}

/* Modal footer buttons — shared base */
.modal-footer .btn-secondary,
.modal-footer .btn-primary,
.modal-footer .btn-danger {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  border-radius: 0;
  padding: 8px 20px;
}

.modal-footer .btn-secondary {
  background: transparent;
  border: 1.5px solid rgba(26,20,16,0.3);
  color: var(--charcoal);
}

/* Modal primary and danger share seal-red fill */
.modal-footer .btn-primary,
.modal-footer .btn-danger {
  background: var(--seal-red);
  border: none;
  color: var(--surface);
  box-shadow: 2px 2px 0 rgba(26,20,16,0.3);
}

.modal-footer .btn-primary {
  background: var(--seal-red) !important;
  border: none !important;
  color: var(--surface) !important;
  box-shadow: 2px 2px 0 rgba(26,20,16,0.3) !important;
}

/* ── Form pages (create / edit) ───────────────────────────── */

/* Form labels */
.col-form-label,
label.form-label {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px !important;
  color: var(--charcoal);
  letter-spacing: 0.02em;
}

/* Form inputs */
.form-control {
  background: var(--paper) !important;
  border: 1.5px solid rgba(26,20,16,0.22) !important;
  border-radius: 0 !important;
  padding: 9px 12px;
  font-family: 'Noto Serif', serif;
  font-size: 16px;
  color: var(--ink) !important;
  box-shadow: inset 0 1px 3px rgba(26,20,16,0.05) !important;
}

.form-control:focus {
  border-color: var(--seal-red) !important;
  box-shadow: 0 0 0 2px rgba(192,57,43,0.10), inset 0 1px 3px rgba(26,20,16,0.05) !important;
  outline: none;
}

.form-control::placeholder {
  color: var(--faded-ink);
  font-style: italic;
}

/* Disabled / read-only field (edit screen characters) */
.form-control:disabled,
.form-control[disabled] {
  background: var(--paper-dark) !important;
  border: 1.5px solid rgba(26,20,16,0.13) !important;
  color: var(--faded-ink) !important;
  font-family: 'KaiTi', serif;
  font-size: 20px;
  box-shadow: inset 0 2px 5px rgba(26,20,16,0.08) !important;
  pointer-events: none;
  cursor: default;
  opacity: 1 !important;
  letter-spacing: 0.05em;
}

/* Primary action button (Create / Save) */
.btn-primary {
  background: var(--seal-red) !important;
  color: var(--surface) !important;
  border: none !important;
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  letter-spacing: 0.05em;
  padding: 11px 0;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(26,20,16,0.30) !important;
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0 !important;
}

.btn-primary:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(26,20,16,0.30) !important;
}

.btn-primary:hover {
  background: var(--seal-light) !important;
  color: var(--surface) !important;
}

/* Secondary action button (Add Another / Cancel) */
.btn-secondary {
  background: transparent !important;
  border: 1.5px solid rgba(26,20,16,0.30) !important;
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  color: var(--charcoal) !important;
  padding: 11px 0;
  cursor: pointer;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.btn-secondary:active {
  background: var(--paper-dark) !important;
}

/* Customise button in create form (btn-sm btn-secondary) */
.btn-sm.btn-secondary {
  padding: 6px 10px;
  font-size: 18px;
}

/* ── Create form: radio selection area ───────────────────── */
.input-group-text {
  background: var(--paper);
  border: 1.5px solid rgba(26,20,16,0.22);
  border-radius: 0;
  color: var(--charcoal);
  font-family: 'Noto Serif', serif;
}

/* ── Flashed alerts ───────────────────────────────────────── */
.alert {
  border-radius: 1px;
  font-family: 'Noto Serif', serif;
  font-size: 16px;
}

.alert-primary,
.alert-success {
  background: rgba(26,20,16,0.05);
  border: 1.5px solid rgba(26,20,16,0.2);
  color: var(--charcoal);
}

.alert-danger {
  background: rgba(192,57,43,0.08);
  border: 1.5px solid rgba(192,57,43,0.35);
  color: var(--seal-red);
}

/* ── Auth screen ──────────────────────────────────────────── */
.auth-page-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh;
  padding: 0 20px;
  overflow: hidden;
}

/* Hero title */
.auth-hero {
  text-align: center;
  margin-bottom: 32px;
}

.auth-hero-title {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 36px;
  line-height: 1.15;
  color: var(--ink);
  text-shadow:
    0 1px 4px rgba(26,20,16,0.12),
    1px 1px 0   rgba(26,20,16,0.05);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.auth-hero-subtitle {
  font-family: 'Noto Serif', serif;
  font-weight: 400;
  font-size: 16px;
  color: var(--charcoal);
  line-height: 1.5;
  letter-spacing: 0.01em;
}

/* Auth card */
.auth-card {
  background: var(--surface);
  border: 1.5px solid rgba(26,20,16,0.20);
  box-shadow:
    3px 4px 14px rgba(26,20,16,0.10),
    inset 0 1px 0 rgba(255,255,255,0.65);
  padding: 24px 22px 22px;
  border-radius: 0;
  width: 100%;
}

.auth-page-wrap.privacy-page {
  overflow-y: auto;
  height: auto;
  min-height: 100dvh;
  align-items: flex-start;
  padding-top: 40px;
  padding-bottom: 40px;
}

/* Nav tabs: ink-style */
.nav-tabs {
  border-bottom: 1.5px solid rgba(26,20,16,0.15) !important;
  margin-bottom: 22px;
}

.nav-tabs .nav-link {
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  color: var(--faded-ink);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  padding: 8px 16px 10px;
  letter-spacing: 0.05em;
  transition: color 0.15s;
  border-radius: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-tabs .nav-link.active {
  color: var(--ink) !important;
  border-bottom-color: var(--seal-red) !important;
  background: none !important;
  border-top: none;
  border-left: none;
  border-right: none;
}

.nav-tabs .nav-link:hover {
  color: var(--ink);
  border-bottom-color: rgba(192,57,43,0.4);
}

/* Passkey button */
.btn-passkey,
#signinBtn,
#registerBtn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--seal-red) !important;
  color: var(--surface) !important;
  border: none !important;
  font-family: 'ZCOOL QingKe HuangYou', serif;
  font-size: 18px;
  letter-spacing: 0.06em;
  padding: 14px 0 !important;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(26,20,16,0.35) !important;
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0 !important;
}

#signinBtn:active,
#registerBtn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(26,20,16,0.35) !important;
}

/* Auth link (Forgot your passkey?) */
.auth-link,
.tab-pane .text-center a,
.tab-pane .small a,
.mt-3.text-center.small a {
  font-family: system-ui, sans-serif;
  font-size: 16px;
  color: var(--seal-red);
  text-decoration: none;
  border-bottom: 1px solid rgba(192,57,43,0.4);
  padding-bottom: 1px;
}

/* Error text */
#signinError,
#registerError,
#addPasskeyError,
.text-danger.small {
  font-family: system-ui, sans-serif;
  font-size: 16px;
  color: var(--seal-red) !important;
}

/* ── Toast notifications ──────────────────────────────────── */
.toast {
  background: var(--surface) !important;
  border: 1.5px solid rgba(26,20,16,0.15) !important;
  border-radius: 1px !important;
}

.toast-body {
  font-family: 'Noto Serif', serif;
  font-size: 16px;
  color: var(--ink);
}

/* ── #create form label width ─────────────────────────────── */
#create .col-form-label {
  min-width: 100px;
}

/* ── jQuery UI autocomplete ───────────────────────────────── */
.ui-autocomplete {
  background: var(--surface) !important;
  border: 1.5px solid rgba(26,20,16,0.22) !important;
  border-radius: 0 !important;
  box-shadow: 2px 4px 10px rgba(26,20,16,0.12) !important;
  font-family: 'Noto Serif', serif;
}

.ui-menu-item-wrapper {
  font-family: 'Noto Serif', serif;
  font-size: 16px;
  color: var(--charcoal) !important;
  padding: 6px 10px !important;
}

.ui-state-active,
.ui-menu-item-wrapper.ui-state-active {
  background: rgba(192,57,43,0.08) !important;
  border: none !important;
  color: var(--ink) !important;
}
