@font-face { font-family: "Cinzel"; src: url("fonts/Cinzel.ttf") format("truetype"); font-weight: 400 900; }
@font-face { font-family: "Cinzel Decorative"; src: url("fonts/CinzelDecorative-Bold.ttf") format("truetype"); font-weight: 700; }
@font-face { font-family: "EB Garamond"; src: url("fonts/EBGaramond.ttf") format("truetype"); font-weight: 400 800; }
@font-face { font-family: "EB Garamond"; src: url("fonts/EBGaramond-Italic.ttf") format("truetype"); font-style: italic; font-weight: 400 800; }

:root {
  --parchment: #f4ead2;
  --parchment-dark: #e4d3ad;
  --ink: #2c1d12;
  --ink-soft: #5c4430;
  --accent: #7a2416;
  --sea-deep: #829a99;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; width: 100%; overflow: hidden;
  background: var(--sea-deep) url("sea_bg.jpg") repeat;
  color: var(--ink); font-family: "EB Garamond", Georgia, serif;
}

#map {
  position: fixed; inset: 0;
  background: var(--sea-deep) url("sea_bg.jpg") repeat;
}
.leaflet-container {
  background: var(--sea-deep) url("sea_bg.jpg") repeat !important;
  font-family: "EB Garamond", Georgia, serif;
}
.leaflet-control-zoom {
  margin-top: 84px !important;
  margin-left: 14px !important;
  border: 2px solid #7c5c38 !important;
  box-shadow: 0 4px 14px rgba(30, 18, 8, .35) !important;
}
.leaflet-control-zoom a {
  background: var(--parchment) !important;
  color: var(--ink) !important;
  border-bottom-color: #b89a72 !important;
  font-family: "Cinzel", serif !important;
}
.leaflet-control-zoom a:hover {
  background: var(--parchment-dark) !important;
  color: var(--accent) !important;
}

#bar {
  position: fixed; top: 12px; left: 14px; right: 14px; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 18px;
  max-width: 1180px; margin: 0 auto;
  background: linear-gradient(180deg, rgba(248, 238, 212, .95), rgba(232, 214, 176, .94));
  border: 2px solid #7c5a36; border-radius: 8px;
  box-shadow: 0 6px 22px rgba(28, 16, 8, .42), inset 0 0 0 1px rgba(255, 248, 230, .6);
  backdrop-filter: blur(4px);
}
#brand {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  line-height: 1.05; min-width: 245px; cursor: pointer;
}
#brand .brand-emblem {
  width: 30px; height: 30px; flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(36, 20, 10, .35));
}
#brand .brand-text {
  display: flex; flex-direction: column;
}
#brand .title {
  margin: 0;
  font-family: "Cinzel Decorative", "Cinzel", serif; font-weight: 700; font-size: 22px;
  color: var(--accent); letter-spacing: .05em; text-shadow: 0 1px 0 rgba(255, 250, 235, .8);
}
#brand .subtitle { font-style: italic; font-size: 13px; color: var(--ink-soft); }
.noscript-seo {
  position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 2000;
  max-width: 760px; margin: 0 auto; padding: 16px 20px;
  background: var(--parchment); border: 2px solid #7c5a36; border-radius: 8px;
}

#searchbox { position: relative; flex: 1; max-width: 500px; }
#q {
  width: 100%; font: inherit; font-size: 17px; padding: 6px 12px; border-radius: 6px;
  border: 1px solid #8e6e48; background: #fcf7ea; color: var(--ink); outline: none;
}
#q:focus { box-shadow: 0 0 0 2px rgba(122, 36, 22, .28); }
#results {
  position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 4px 0; list-style: none;
  background: #fcf7ea; border: 1.5px solid #8a6a46; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(30, 18, 8, .38);
  display: none; max-height: 62vh; overflow: auto;
}
#results li { padding: 7px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
#results li .en { color: var(--ink-soft); font-style: italic; font-weight: 400; font-size: 14px; }
#results li.active, #results li:hover { background: #ede0be; }

#controls { display: flex; align-items: center; gap: 8px; }
#home-btn, #about-btn {
  font-family: "Cinzel", serif; font-weight: 600; font-size: 12.5px; padding: 6px 11px;
  border: 1px solid #8e6e48; border-radius: 5px; background: #fcf7ea; color: var(--ink); cursor: pointer;
  white-space: nowrap;
}
#home-btn:hover, #about-btn:hover { background: #ede0be; color: var(--accent); }
#langs button {
  font-family: "Cinzel", serif; font-weight: 600; font-size: 13px; padding: 5px 10px;
  border: 1px solid #8e6e48; background: #fcf7ea; color: var(--ink); cursor: pointer;
}
#langs button:first-child { border-radius: 5px 0 0 5px; }
#langs button:last-child { border-radius: 0 5px 5px 0; border-left: none; }
#langs button.on { background: var(--accent); color: #fbf0d9; }

#hover-tip {
  position: fixed; z-index: 950; pointer-events: none; display: none;
  background: rgba(248, 238, 212, .96); border: 1.5px solid #784828; border-radius: 6px;
  padding: 6px 11px; box-shadow: 0 4px 14px rgba(24, 14, 6, .38);
  max-width: 310px; transform: translate(14px, -18px);
}
#hover-tip .ht-name {
  font-family: "Cinzel", serif; font-weight: 700; font-size: 14.5px; color: var(--accent); line-height: 1.2;
}
#hover-tip .ht-sub {
  font-style: italic; font-size: 13px; color: var(--ink-soft); line-height: 1.2; margin-top: 1px;
}
#hover-tip .ht-reg {
  font-size: 12px; color: var(--ink); margin-top: 2px; border-top: 1px solid rgba(140, 108, 72, .35); padding-top: 2px;
}

#panel {
  position: fixed; top: 76px; right: 14px; width: 390px; max-height: calc(100% - 96px); overflow: auto; z-index: 1000;
  background: var(--parchment); border: 2px solid #7c5a36; border-radius: 8px; padding: 18px 20px 16px;
  box-shadow: 0 10px 30px rgba(28, 16, 8, .48); display: none;
  background-image: radial-gradient(ellipse at center, rgba(255,255,255,.4), rgba(0,0,0,0) 72%);
}
#panel.open { display: block; }
#close { position: absolute; top: 6px; right: 10px; border: none; background: none; font-size: 26px; color: var(--ink-soft); cursor: pointer; }
#panel h2 { font-family: "Cinzel", serif; font-weight: 700; font-size: 22px; margin: 0 26px 2px 0; color: var(--accent); line-height: 1.15; }
#panel .alt { font-style: italic; color: var(--ink-soft); margin-bottom: 8px; }
#panel .type { display: inline-block; font-family: "Cinzel", serif; font-weight: 600; font-size: 12px; letter-spacing: .05em; padding: 2px 8px; border: 1px solid #9a7850; border-radius: 10px; margin-bottom: 8px; background: rgba(255,255,255,.35); }
#panel img { width: 100%; max-height: 220px; object-fit: cover; border: 1px solid #9a7850; border-radius: 4px; margin: 6px 0 8px; }
#panel .regions { font-size: 14.5px; color: var(--ink-soft); margin: 4px 0 10px; }
#panel .regions b { color: var(--ink); font-weight: 700; }

.lang-cards { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 12px; }
.lang-card {
  background: linear-gradient(180deg, rgba(236, 221, 186, .85), rgba(224, 206, 166, .9));
  border: 1px solid #b59669; border-radius: 6px; padding: 9px 11px;
  box-shadow: inset 0 1px 0 rgba(255, 250, 236, .6);
}
.lang-card.absent { opacity: .62; }
.lc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px; border-bottom: 1px solid rgba(154, 120, 80, .35); padding-bottom: 4px;
}
.lc-lang {
  font-family: "Cinzel", serif; font-weight: 700; font-size: 13px; color: var(--ink); letter-spacing: .04em;
}
.lc-rank {
  font-family: "Cinzel", serif; font-weight: 700; font-size: 11.5px; color: var(--accent);
  background: rgba(255, 248, 230, .7); border: 1px solid #b8986c; border-radius: 10px; padding: 1px 7px;
}
.lc-metric { margin: 5px 0; }
.lc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-size: 13.5px; line-height: 1.25; margin-bottom: 3px;
}
.lc-label { color: var(--ink-soft); font-size: 13px; display: flex; align-items: center; gap: 5px; }
.lc-val { font-weight: 700; color: var(--ink); font-size: 14px; }
.lc-val small { font-weight: 600; color: var(--ink-soft); font-size: 12px; margin-left: 3px; }
.q-icon {
  height: 20px; width: auto; object-fit: contain; vertical-align: middle;
  filter: drop-shadow(0 1px 1.5px rgba(28, 16, 8, .32));
}
.pbar {
  position: relative; height: 9px; width: 100%;
  background: rgba(60, 42, 24, .18); border: 1px solid rgba(92, 66, 38, .55);
  border-radius: 5px; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(20, 12, 4, .28);
}
.pbar-fill {
  height: 100%; border-radius: 4px;
  transition: width .35s cubic-bezier(.22, .61, .36, 1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .42), inset 0 -1px 0 rgba(0, 0, 0, .2);
}
.lc-links {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 7px; padding-top: 5px; border-top: 1px dashed rgba(154, 120, 80, .4);
  font-size: 13px;
}
.lc-links a {
  color: var(--accent); font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.lc-links a:hover { text-decoration: underline; }
.wd-link { font-size: 13.5px; margin: 4px 0 8px; }
.wd-link a { color: var(--accent); font-weight: 700; text-decoration: none; }
.wd-link a:hover { text-decoration: underline; }

#panel p.abstract { font-size: 16px; line-height: 1.38; margin: 6px 0 10px; }
#panel h3 { font-family: "Cinzel", serif; font-weight: 700; font-size: 14px; letter-spacing: .06em; margin: 14px 0 4px; border-bottom: 1px solid #b89a72; }
#panel ul.related { list-style: none; padding: 0; margin: 4px 0 0; }
#panel ul.related li { padding: 3px 0; cursor: pointer; color: var(--ink); font-weight: 600; }
#panel ul.related li:hover { color: var(--accent); text-decoration: underline; }

#legend {
  position: fixed; left: 14px; bottom: 26px; z-index: 900;
  background: rgba(244, 234, 210, .94); border: 1.5px solid #7c5a36;
  border-radius: 7px; padding: 9px 13px; font-size: 13.5px; line-height: 1.48;
  box-shadow: 0 5px 16px rgba(28, 16, 8, .35); max-width: 275px;
}
#legend .lg-title { font-family: "Cinzel", serif; font-weight: 700; font-size: 13.5px; color: var(--accent); margin-bottom: 2px; }
#legend .lg-note { font-style: italic; font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; line-height: 1.25; }
.ic { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 1.5px solid #68221a; background: #eee2c6; }
.ic.castle { border-radius: 1px; box-shadow: inset 0 -4px 0 #eee2c6; }
.ic.tower { border-radius: 6px 6px 1px 1px; background: #b05c3c; }
.ic.house { clip-path: polygon(50% 0, 100% 45%, 100% 100%, 0 100%, 0 45%); background: #96402a; border: none; }
.ic.shield { border-radius: 2px 2px 8px 8px; background: #d6c496; }
.ic.diamond { transform: rotate(45deg) scale(.8); }
.ic.star { clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: #deb446; border: none; }
.ic.dot { border-radius: 50%; }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #7a2416; background: rgba(251, 240, 217, .55); box-shadow: 0 0 0 3px rgba(251, 240, 217, .75); }
.leaflet-control-attribution { font-size: 11px; background: rgba(244, 234, 210, .86) !important; color: var(--ink) !important; }

#about-backdrop {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(24, 16, 10, .58); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
#about-backdrop.open { display: flex; }
#about-modal {
  position: relative; max-width: 680px; width: 100%; max-height: 88vh; overflow: auto;
  background: var(--parchment); border: 2.5px solid #785432; border-radius: 10px;
  padding: 22px 26px 20px; box-shadow: 0 14px 42px rgba(18, 10, 4, .6), inset 0 0 0 1px rgba(255, 248, 232, .65);
  background-image: radial-gradient(ellipse at center, rgba(255, 255, 255, .42), rgba(0, 0, 0, 0) 75%);
  color: var(--ink); font-size: 16px; line-height: 1.45;
}
#about-close {
  position: absolute; top: 8px; right: 12px; border: none; background: none;
  font-size: 28px; color: var(--ink-soft); cursor: pointer; line-height: 1;
}
#about-close:hover { color: var(--accent); }
#about-modal h2 {
  font-family: "Cinzel Decorative", "Cinzel", serif; font-weight: 700; font-size: 24px;
  color: var(--accent); margin: 0 28px 8px 0; border-bottom: 1.5px solid #b89a72; padding-bottom: 6px;
}
#about-modal .about-lead { font-size: 16.5px; margin: 6px 0 12px; }
#about-modal h3 {
  font-family: "Cinzel", serif; font-weight: 700; font-size: 16px; color: var(--accent);
  margin: 14px 0 6px; letter-spacing: .04em;
}
#about-modal ul { margin: 4px 0 8px; padding-left: 20px; }
#about-modal li { margin-bottom: 7px; }

@media (max-width: 780px) {
  #brand .subtitle, #legend, #home-btn { display: none; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 55%; }
}
