/*
 * LearnExchange themes, layered on the vendored Bootstrap 5.3 build.
 *
 * Both borrow from the old academies of Changsha. A theme is a set of colour
 * variables; <html data-theme="..."> picks one (see ApplicationController::THEMES).
 */

/* Theme "asian red": vermilion columns, grey roof tiles, rice paper. These are also the
 * base values that the other theme overrides. */
:root {
  --te-paper: #f6f0e2;
  --te-paper-light: #fffdf8;
  --te-paper-dark: #ebe2cd;
  --te-wall: #f8f4ea;
  --te-ink: #2b2622;
  --te-ink-soft: #5d554c;
  --te-accent: #a4302a;
  --te-accent-dark: #8f2a25;
  --te-accent-rgb: 164, 48, 42;
  --te-link-rgb: 143, 42, 37;
  --te-link-hover-rgb: 110, 30, 26;
  --te-seal: #a4302a;
  --te-roof: #3a3f44;
  --te-roof-line: #6b7177;
  --te-nav-edge: #2b2622;
  --te-footer: #5b3a29;
  --te-timber: #5b3a29;
  --te-pine: #3f5a4a;
  --te-hill: #5f7a69;
  --te-gold: #c9a24b;
  --te-gold-dark: #8f6c22;
  --te-gold-light: #e3c376;
  --te-plaque: #1f2d3a;
  --te-line: #d6c9ad;
  --te-lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16'%3E%3Cpath d='M0 14H28V2H8V9H20' fill='none' stroke='%235b3a29' stroke-width='2'/%3E%3C/svg%3E");
  --te-serif: "Noto Serif", "Source Serif 4", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;

  --bs-body-bg: var(--te-paper);
  --bs-body-color: var(--te-ink);
  --bs-secondary-color: var(--te-ink-soft);
  --bs-border-color: var(--te-line);
  --bs-link-color-rgb: var(--te-link-rgb);
  --bs-link-hover-color-rgb: var(--te-link-hover-rgb);
  --bs-border-radius: 0.25rem;
}

/*
 * Theme "yuelu green" (the default): the Yuelu Academy gate in spring. White walls, a brown-grey
 * tiled roof edged in gold, a slate wall base, and fresh leaf green all around.
 */
[data-theme="yuelu-green"] {
  --te-paper: #f3f6ec;
  --te-paper-light: #fdfefb;
  --te-paper-dark: #e2e9d6;
  --te-wall: #fbfbf6;
  --te-ink: #26302a;
  --te-ink-soft: #56635a;
  --te-accent: #3f7d3a;
  --te-accent-dark: #2f6230;
  --te-seal: var(--te-accent); /* same green as public/icon.svg */
  --te-accent-rgb: 63, 125, 58;
  --te-link-rgb: 47, 98, 48;
  --te-link-hover-rgb: 34, 74, 36;
  --te-roof: #5b5148;
  --te-roof-line: #81766b;
  --te-nav-edge: #dba63f;
  --te-footer: #5f6b78;
  --te-timber: #4a3b30;
  --te-pine: #4c8f3f;
  --te-hill: #7fb069;
  --te-gold: #dba63f;
  --te-gold-dark: #8a6418;
  --te-gold-light: #f0cd7a;
  --te-plaque: #2a2420;
  --te-line: #cbd5bd;
  --te-lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16'%3E%3Cpath d='M0 14H28V2H8V9H20' fill='none' stroke='%233f7d3a' stroke-width='2'/%3E%3C/svg%3E");
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .navbar-brand, .display-4, .display-6 {
  font-family: var(--te-serif);
}

/* --- Roof: navigation bar with a row of round eave tiles underneath --- */

.site-nav {
  background: var(--te-roof);
  border-bottom: 3px solid var(--te-nav-edge);
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand .brand-accent {
  color: var(--te-gold-light);
  margin-left: -0.5rem;
}

.brand-seal {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.25rem;
  background: var(--te-seal);
  color: #fffdf8;
  font-size: 1.1rem;
  line-height: 1;
}

.eaves {
  height: 9px;
  background: radial-gradient(circle at 9px 0, var(--te-roof) 7px, transparent 8px) repeat-x;
  background-size: 18px 9px;
}

.site-footer {
  background: var(--te-footer);
  color: #f3ecdc;
  border-top: 3px solid var(--te-ink);
}

/* --- Buttons, cards, forms --- */

.btn-primary {
  --bs-btn-bg: var(--te-accent);
  --bs-btn-border-color: var(--te-accent-dark);
  --bs-btn-hover-bg: var(--te-accent-dark);
  --bs-btn-hover-border-color: var(--te-accent-dark);
  --bs-btn-active-bg: var(--te-accent-dark);
  --bs-btn-active-border-color: var(--te-accent-dark);
  --bs-btn-disabled-bg: var(--te-accent);
  --bs-btn-disabled-border-color: var(--te-accent);
}

.btn-outline-primary {
  --bs-btn-color: var(--te-accent-dark);
  --bs-btn-border-color: var(--te-accent-dark);
  --bs-btn-hover-bg: var(--te-accent);
  --bs-btn-hover-border-color: var(--te-accent);
  --bs-btn-active-bg: var(--te-accent-dark);
  --bs-btn-active-border-color: var(--te-accent-dark);
}

.card {
  --bs-card-bg: var(--te-paper-light);
  --bs-card-border-color: var(--te-line);
}

.form-control, .form-select, .list-group-item, .dropdown-menu {
  background-color: var(--te-paper-light);
}

.form-control:focus, .form-select:focus {
  background-color: #fff;
  border-color: var(--te-accent);
  box-shadow: 0 0 0 0.2rem rgba(var(--te-accent-rgb), 0.18);
}

.table {
  --bs-table-bg: transparent;
}

.nav-tabs .nav-link.active {
  background-color: var(--te-paper-light);
}

.token-pill {
  background: var(--te-gold);
  color: var(--te-ink);
  border: 1px solid var(--te-gold-dark);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.skill-photo {
  aspect-ratio: 3 / 2;
  object-fit: cover;
  width: 100%;
}

.skill-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--te-paper-dark);
}

.skill-photo-placeholder .te-icon {
  width: 4rem;
  height: 4rem;
  opacity: 0.55;
}

.member-photo {
  aspect-ratio: 1;
  object-fit: cover;
}

.photo-thumb {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: var(--bs-border-radius);
}

.skill-card .card-text {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stars {
  color: #b7791f;
  letter-spacing: 0.05em;
}

.message {
  max-width: 80%;
  border-radius: 0.75rem;
  padding: 0.5rem 0.9rem;
  background: var(--te-paper-dark);
  overflow-wrap: anywhere;
}

.message p:last-child {
  margin-bottom: 0;
}

.message.mine {
  margin-left: auto;
  background: var(--te-paper-light);
  border: 1px solid var(--te-line);
}

.prose {
  overflow-wrap: anywhere;
}

/* --- Front page --- */

.hero {
  background: linear-gradient(var(--te-paper-light), var(--te-paper));
  border-bottom: 1px solid var(--te-line);
}

.motto {
  font-family: var(--te-serif);
  color: var(--te-accent-dark);
  font-size: 1.5rem;
  letter-spacing: 0.15em;
}

.motto-translation {
  font-size: 0.95rem;
  letter-spacing: 0;
  font-style: italic;
  color: var(--te-ink-soft);
  display: inline-block;
}

.academy-art, .cycle-art {
  display: block;
  width: 100%;
  height: auto;
}

.cycle-art {
  max-width: 520px;
  margin-inline: auto;
}

.cycle-name {
  font-family: var(--te-serif);
  font-size: 18px;
  font-weight: 700;
  fill: var(--te-ink);
}

.cycle-label {
  font-size: 15px;
  fill: var(--te-accent-dark);
  font-weight: 600;
}

.cycle-strong {
  font-size: 15px;
  font-weight: 600;
  fill: var(--te-ink);
}

.cycle-story {
  padding-left: 1.25rem;
  font-size: 1.1rem;
}

.cycle-story li {
  margin-bottom: 0.35rem;
}

.cycle-story li::marker {
  color: var(--te-accent);
  font-weight: 700;
}

/* Section headings carry a small seal mark. */
.section-title {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-title::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  background: var(--te-accent);
  border-radius: 2px;
  flex: none;
}

/* A strip of window lattice between sections. */
.lattice {
  height: 16px;
  margin: 1rem 0;
  opacity: 0.55;
  background: var(--te-lattice) repeat-x center;
}

.te-icon {
  width: 64px;
  height: 64px;
}

/* How it works: three stops joined by arrows. */
.flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem;
}

.flow-step {
  position: relative;
  text-align: center;
  background: var(--te-paper-light);
  border: 1px solid var(--te-line);
  border-top: 4px solid var(--te-roof);
  border-radius: 0.25rem;
  padding: 1.25rem 1rem;
}

.flow-step + .flow-step::before {
  content: "→";
  position: absolute;
  left: -2.5rem;
  width: 2.5rem;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 2rem;
  line-height: 1;
  color: var(--te-accent);
}

/* Where the token is while a lesson is pending. */
.escrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.escrow-stop {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 7.5rem;
  padding: 1rem;
  background: var(--te-paper-light);
  border: 1px solid var(--te-line);
  border-radius: 0.25rem;
}

.escrow-held {
  border: 2px dashed var(--te-accent);
}

.escrow-leg {
  flex: 1;
  text-align: center;
  font-size: 0.95rem;
  color: var(--te-ink-soft);
  border-bottom: 2px dashed var(--te-accent);
  position: relative;
  padding-bottom: 0.35rem;
}

.escrow-leg::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -7px;
  border: 6px solid transparent;
  border-left-color: var(--te-accent);
  border-right: 0;
}

.escrow-back {
  margin-top: 0.75rem;
  color: var(--te-ink-soft);
}

.escrow-return {
  color: var(--te-accent);
  font-weight: 700;
  font-size: 1.2rem;
}

/* An old cash coin: round with a square hole. */
.coin {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--te-gold);
  border: 2px solid var(--te-gold-dark);
  position: relative;
}

.coin::after {
  content: "";
  position: absolute;
  inset: 0.7rem;
  background: var(--te-paper-light);
  border: 1.5px solid var(--te-gold-dark);
}

.area-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  height: 100%;
  padding: 1rem 0.75rem;
  text-align: center;
  text-decoration: none;
  color: var(--te-ink);
  background: var(--te-paper-light);
  border: 1px solid var(--te-line);
  border-radius: 0.25rem;
  transition: border-color 0.15s, transform 0.15s;
}

.area-tile:hover, .area-tile:focus-visible {
  border-color: var(--te-accent);
  transform: translateY(-2px);
}

.area-name {
  font-family: var(--te-serif);
  font-weight: 700;
}

.area-sample {
  font-size: 0.85rem;
  color: var(--te-ink-soft);
}

@media (max-width: 767.98px) {
  .flow {
    grid-template-columns: 1fr;
  }

  .flow-step + .flow-step::before {
    content: "↓";
    left: 0;
    width: 100%;
    top: -2.5rem;
    transform: none;
    height: 2.5rem;
    line-height: 2.5rem;
  }

  .escrow {
    flex-direction: column;
    align-items: stretch;
  }

  .escrow-leg {
    border-bottom: 0;
    padding: 0.25rem 0;
  }

  .escrow-leg::before {
    content: "↓ ";
    color: var(--te-accent);
  }

  .escrow-leg::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .area-tile {
    transition: none;
  }
}
