:root {
  --cream: #f5ecd6;
  --cream-deep: #ecdfc0;
  --paper: #fbf5e3;
  --brown: #5a3a22;
  --brown-dark: #3d2614;
  --brown-light: #7a5235;
  --orange: #d99440;
  --orange-bright: #f0a85a;
  --ink: #2a1a0e;
  --muted: #6e5840;
  --shadow: rgba(58, 36, 18, 0.25);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Iowan Old Style", "Palatino Linotype", "Palatino", Georgia, serif;
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh;
  line-height: 1.4;
}

/* ===== Header / search ===== */

.page-header {
  padding: 24px 32px 16px;
  background: var(--cream-deep);
  border-bottom: 2px solid var(--brown);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-header h1 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 700;
  font-style: italic;
  color: var(--brown-dark);
}

.subtitle {
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  font-size: 18px;
}

.search-wrap {
  position: relative;
  max-width: 720px;
}

#search {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 12px 16px;
  border: 2px solid var(--brown);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search::placeholder {
  color: var(--muted);
  font-style: italic;
}

#search:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(217, 148, 64, 0.25);
}

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--paper);
  border: 2px solid var(--brown);
  border-radius: 6px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 8px 24px var(--shadow);
}

.suggestions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  cursor: pointer;
}

.suggestions li.is-highlighted,
.suggestions li:hover {
  background: var(--orange);
  color: var(--paper);
}

.suggestions .badge {
  font-size: 13px;
  font-weight: 700;
  background: var(--brown);
  color: var(--orange-bright);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.suggestions li.is-highlighted .badge,
.suggestions li:hover .badge {
  background: var(--brown-dark);
  color: var(--orange-bright);
}

.suggestions .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Layout ===== */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 32px;
  padding: 24px 32px 48px;
  align-items: start;
}

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

.maps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-width: 0;
}

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

.floor h2 {
  margin: 0 0 12px;
  text-align: center;
  font-style: italic;
  font-size: 22px;
  color: var(--brown-dark);
  border-bottom: 2px solid var(--brown);
  padding-bottom: 6px;
}

/* ===== Floor map ===== */

.floor-map {
  --row-h: 44px;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  grid-auto-rows: var(--row-h);
  row-gap: 12px;
  column-gap: 0;
  padding: 16px 8px 0;
  background: var(--paper);
  border: 2px solid var(--brown);
  border-radius: 8px 8px 60% 60% / 8px 8px 80px 80px;
  min-height: 480px;
}

/* Top wall row holds the small wall sections (1M/1N or 2M-2Q) */
.floor-map .wall-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  height: 32px;
}

/* Decorative inner tables (floor 1 only) */
.floor-map .table {
  background: var(--cream-deep);
  border: 1px solid var(--brown-light);
  border-radius: 2px;
  align-self: center;
  justify-self: center;
  width: 28px;
  height: 20px;
}

.floor-map .table.t1 {
  grid-column: 2;
  grid-row: 4;
}

.floor-map .table.t2 {
  grid-column: 2;
  grid-row: 5;
  width: 24px;
  height: 36px;
}

.floor-map .dot {
  grid-column: 2;
  width: 4px;
  height: 4px;
  background: var(--brown);
  border-radius: 50%;
  justify-self: center;
  align-self: center;
}

/* Stairs at the bottom */
.floor-map .stairs {
  grid-column: 1 / -1;
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 56px;
  font-style: italic;
  color: var(--muted);
  background:
    repeating-linear-gradient(
      90deg,
      var(--cream-deep) 0,
      var(--cream-deep) 6px,
      var(--paper) 6px,
      var(--paper) 8px
    );
  border-top: 1px solid var(--brown-light);
  border-radius: 0 0 60% 60% / 0 0 100% 100%;
}

/* Cells that hold a section button + label */
.floor-map .cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.floor-map .cell.left {
  grid-column: 1;
  justify-content: flex-end;
  flex-direction: row;
}

.floor-map .cell.right {
  grid-column: 3;
  justify-content: flex-start;
}

/* Section button styling */
.section {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--brown);
  color: var(--orange-bright);
  border: 2px solid var(--brown-dark);
  border-radius: 4px;
  padding: 6px 10px;
  min-width: 44px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  /* orange tab on the inner edge */
}

.section::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--orange);
}

.cell.left .section::before {
  right: 0;
  border-radius: 0 2px 2px 0;
}

.cell.right .section::before {
  left: 0;
  border-radius: 2px 0 0 2px;
}

.wall-row .section {
  min-width: 32px;
  min-height: 26px;
  padding: 4px 6px;
  font-size: 12px;
}

.wall-row .section::before {
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  height: 5px;
  width: auto;
  border-radius: 0 0 2px 2px;
}

.section:hover,
.section:focus-visible {
  outline: none;
  transform: scale(1.06);
  box-shadow: 0 4px 12px var(--shadow);
}

.section.is-active {
  border-color: var(--orange);
  box-shadow:
    0 0 0 3px var(--orange),
    0 6px 18px var(--shadow);
  animation: pulse 1.6s ease-out 1;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(217, 148, 64, 0.7), 0 6px 18px var(--shadow); }
  100% { box-shadow: 0 0 0 14px rgba(217, 148, 64, 0),  0 6px 18px var(--shadow); }
}

.section-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .section-label {
    font-size: 12px;
  }
}

@media (max-width: 880px) {
  .floor-map { grid-template-columns: 1fr 40px 1fr; }
  .section-label { display: none; }
}

/* ===== Detail panel ===== */

.detail {
  position: sticky;
  top: 140px;
  background: var(--paper);
  border: 2px solid var(--brown);
  border-radius: 8px;
  padding: 20px 22px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  box-shadow: 0 4px 12px var(--shadow);
}

@media (max-width: 960px) {
  .detail {
    position: static;
    max-height: none;
  }
}

.detail-empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 32px 8px;
}

.detail h3 {
  margin: 0 0 4px;
  font-size: 22px;
  color: var(--brown-dark);
}

.detail .detail-code {
  display: inline-block;
  background: var(--brown);
  color: var(--orange-bright);
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: 700;
  margin-right: 8px;
}

.detail .tip {
  margin: 14px 0 0;
  padding: 10px 14px;
  background: rgba(217, 148, 64, 0.15);
  border-left: 4px solid var(--orange);
  border-radius: 0 4px 4px 0;
  font-style: italic;
  font-size: 14px;
}

.detail .shelf-group {
  margin-top: 20px;
}

.detail .shelf-group h4 {
  margin: 0 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--cream-deep);
  padding-bottom: 4px;
}

.detail ol {
  margin: 0;
  padding-left: 32px;
}

.detail li {
  padding: 4px 0;
  line-height: 1.35;
}

.detail li.is-emphasised {
  font-weight: 700;
  color: var(--brown-dark);
  background: rgba(217, 148, 64, 0.18);
  border-radius: 4px;
  padding-left: 4px;
  margin-left: -4px;
}

.detail li.is-emphasised::marker {
  color: var(--orange);
  font-weight: 700;
}

/* Hide scrollbar styling — keep subtle */
.detail::-webkit-scrollbar,
.suggestions::-webkit-scrollbar { width: 8px; }
.detail::-webkit-scrollbar-thumb,
.suggestions::-webkit-scrollbar-thumb {
  background: var(--brown-light);
  border-radius: 4px;
}
