/* ————————————————————————————————————————————————
   ALEXANDRIA — the living encyclopedia
   library-green night · lamplight gold · papyrus
   ———————————————————————————————————————————————— */

:root {
  --night: #0a100d;
  --night-2: #101713;
  --gold: #c8a558;
  --gold-bright: #e6c887;
  --lapis: #5b7fae;
  --bone: #e7e0cf;
  --muted: #7f7a68;
  --line: rgba(200, 165, 88, 0.24);
  --display: "Cinzel", serif;
  --grand: "Cinzel Decorative", serif;
  --body: "Spectral", Georgia, serif;
  --arabic: "Amiri", serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--night); }
body {
  background:
    radial-gradient(1100px 640px at 50% -200px, rgba(200, 165, 88, 0.07), transparent 60%),
    var(--night);
  color: var(--bone);
  font-family: var(--body);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--gold); color: var(--night); }

body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.05'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ———— gate ———— */
#gate {
  position: fixed; inset: 0;
  z-index: 200;
  background:
    radial-gradient(720px 440px at 50% 38%, rgba(200, 165, 88, 0.1), transparent 70%),
    var(--night);
  display: grid;
  place-items: center;
  text-align: center;
  transition: opacity 2s var(--ease-out), visibility 2s;
}
#gate.gate--open { opacity: 0; visibility: hidden; }
.gate__ar { font-family: var(--arabic); font-size: clamp(24px, 3.4vw, 38px); color: var(--lapis); margin-bottom: 22px; }
.gate__title {
  font-family: var(--grand);
  font-weight: 400;
  font-size: clamp(40px, 9vw, 112px);
  letter-spacing: 0.1em;
  color: var(--gold-bright);
  text-shadow: 0 8px 60px rgba(200, 165, 88, 0.25);
}
.gate__sub { margin-top: 14px; font-style: italic; color: var(--muted); font-size: clamp(15px, 1.9vw, 20px); }
.gate__rule { width: 1px; height: 64px; margin: 34px auto 28px; background: linear-gradient(var(--gold), transparent); }
#enter {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--night);
  background: var(--gold);
  border: 0;
  padding: 17px 44px 15px;
  cursor: pointer;
  transition: background 0.5s, letter-spacing 0.5s;
}
#enter:hover { background: var(--gold-bright); letter-spacing: 0.52em; }

/* ———— bar ———— */
.bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px clamp(18px, 4vw, 48px);
  opacity: 0;
  transition: opacity 1.2s 0.9s;
  pointer-events: none;
}
body.entered .bar { opacity: 1; pointer-events: auto; }
.bar__name {
  font-family: var(--grand);
  font-size: 17px;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  text-decoration: none;
  white-space: nowrap;
}
.bar__right { display: flex; gap: 10px; align-items: center; }
.bar button, .bar .bar__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 16, 13, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 9px 15px;
  cursor: pointer;
  transition: color 0.4s, border-color 0.4s;
}
.bar button:hover, .bar .bar__link:hover { color: var(--bone); border-color: var(--gold); }
.lang button.is-on { color: var(--gold-bright); border-color: var(--gold); }
.lang { display: flex; gap: 6px; }

/* ———— hall ———— */
#hall {
  min-height: 92vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 110px 20px 40px;
}
.hall__ar { font-family: var(--arabic); font-size: clamp(22px, 3vw, 34px); color: var(--lapis); margin-bottom: 18px; }
.pharos { margin-bottom: 10px; }
.pharos svg {
  width: clamp(120px, 16vw, 190px);
  height: auto;
  filter: drop-shadow(0 6px 34px rgba(200, 165, 88, 0.35));
}
.pharos__stone { fill: var(--gold); }
.pharos__flame { fill: var(--gold-bright); }
.pharos__beam { fill: var(--gold-bright); opacity: 0.16; animation: beam 5.5s ease-in-out infinite; transform-origin: 80px 19px; }
.pharos__beam:last-of-type { animation-delay: 2.75s; }
@keyframes beam { 0%, 100% { opacity: 0.08; } 50% { opacity: 0.3; } }
.pharos-mark { width: 20px; height: 16px; margin-right: 6px; vertical-align: -2px; color: var(--gold); }
.bar__name { display: inline-flex; align-items: center; }
.hall__note {
  margin: 34px auto 0;
  max-width: 560px;
  font-size: 14.5px;
  font-style: italic;
  color: var(--muted);
}
.hall__note a { color: var(--gold); text-decoration: none; }
.hall__note a:hover { color: var(--gold-bright); }
.hall__title {
  font-family: var(--grand);
  font-weight: 400;
  font-size: clamp(44px, 9.5vw, 124px);
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  text-shadow: 0 10px 70px rgba(200, 165, 88, 0.22);
}
.hall__sub { margin: 14px 0 40px; font-style: italic; color: rgba(231, 224, 207, 0.7); font-size: clamp(16px, 2vw, 21px); }

/* the great search */
.search {
  position: relative;
  width: min(760px, 94vw);
  margin: 0 auto;
}
#q {
  width: 100%;
  background: rgba(16, 23, 19, 0.85);
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--gold);
  color: var(--bone);
  font-family: var(--body);
  font-size: clamp(18px, 2.4vw, 24px);
  padding: 22px 28px;
  outline: none;
  transition: box-shadow 0.5s, border-color 0.5s;
}
#q:focus { box-shadow: 0 24px 80px -20px rgba(200, 165, 88, 0.35); border-color: var(--gold-bright); }
#q::placeholder { color: rgba(127, 122, 104, 0.8); font-style: italic; }
#suggestions {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: rgba(10, 16, 13, 0.97);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
  max-height: 420px;
  overflow-y: auto;
}
#suggestions:empty { display: none; }
.sug {
  background: none;
  border: 0;
  border-bottom: 1px solid rgba(200, 165, 88, 0.08);
  color: var(--bone);
  font-family: var(--body);
  font-size: 17px;
  text-align: start;
  padding: 14px 26px;
  cursor: pointer;
  transition: background 0.25s, padding-left 0.25s, color 0.25s;
}
.sug:hover, .sug:focus { background: rgba(200, 165, 88, 0.1); color: var(--gold-bright); outline: none; }

/* portals + surprise */
.portals {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 36px auto 0;
  max-width: 860px;
}
.portal, #surprise {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--display);
  font-size: 11.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 11px 20px 9px;
  cursor: pointer;
  transition: color 0.4s, border-color 0.4s, background 0.4s;
}
.portal:hover { color: var(--bone); border-color: var(--gold); }
#surprise { border-color: var(--lapis); color: var(--lapis); }
#surprise:hover, #surprise.is-busy { background: var(--lapis); color: var(--night); }

/* results */
#results-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px 80px;
  display: none;
}
#results-wrap.is-open { display: block; }
.results__status { text-align: center; color: var(--muted); font-style: italic; padding: 30px 0; }
.result {
  display: block;
  width: 100%;
  background: rgba(16, 23, 19, 0.55);
  border: 1px solid rgba(200, 165, 88, 0.14);
  color: var(--bone);
  text-align: start;
  font-family: var(--body);
  padding: 18px 24px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.35s, transform 0.35s, background 0.35s;
}
.result:hover { border-color: var(--gold); background: rgba(200, 165, 88, 0.06); transform: translateY(-2px); }
.result__title { display: block; font-family: var(--display); font-size: 17px; letter-spacing: 0.05em; color: var(--gold-bright); margin-bottom: 6px; }
.result__snip { display: block; font-size: 15px; color: rgba(231, 224, 207, 0.66); }

/* ———— reader ———— */
#reader {
  position: fixed; inset: 0;
  z-index: 150;
  background: rgba(8, 12, 10, 0.98);
  display: grid;
  grid-template-rows: auto 1fr;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s var(--ease-out), visibility 0.5s;
}
#reader.is-open { opacity: 1; visibility: visible; }
.reader__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: var(--night);
}
#reader-title {
  flex: 1;
  font-family: var(--display);
  font-size: clamp(15px, 2vw, 20px);
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader__bar button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 9px 15px;
  cursor: pointer;
  transition: color 0.35s, border-color 0.35s, background 0.35s;
}
.reader__bar button:hover { color: var(--bone); border-color: var(--gold); }
#reader-listen.is-playing { background: var(--gold); border-color: var(--gold); color: var(--night); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
#reader-listen.is-playing .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
#reader-frame {
  width: 100%; height: 100%;
  border: 0;
  background: #0d1210;
  opacity: 0;
  transition: opacity 0.45s var(--ease-out);
}
#reader-frame.is-ready { opacity: 1; }

/* ———— colophon ———— */
#colophon {
  border-top: 1px solid rgba(200, 165, 88, 0.12);
  padding: 60px clamp(20px, 5vw, 72px) 44px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
}
#colophon p { max-width: 680px; margin: 0 auto 10px; }
#colophon a { color: var(--gold); text-decoration: none; }
.sandz {
  margin-top: 38px;
  padding-top: 24px;
  border-top: 1px solid rgba(200, 165, 88, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.sandz a { color: var(--gold); text-decoration: none; }
.sandz__mark {
  width: 18px; height: 18px;
  border: 1px solid var(--gold);
  display: inline-grid;
  place-items: center;
  font-size: 9px;
  color: var(--gold);
}

/* galleries dropdown */
.gal { position: relative; }
.gal__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 265px;
  background: rgba(8, 8, 10, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.35s, transform 0.35s, visibility 0.35s;
  z-index: 130;
}
.gal:hover .gal__menu, .gal:focus-within .gal__menu { opacity: 1; visibility: visible; transform: none; }
.gal__menu a {
  display: block;
  padding: 11px 20px 9px;
  font-family: var(--display);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.3s, background 0.3s, padding-left 0.3s;
}
.gal__menu a:hover { color: var(--bone); background: rgba(255, 255, 255, 0.045); padding-left: 26px; }
.gal__menu a span { display: block; font-size: 10px; letter-spacing: 0.1em; opacity: 0.55; text-transform: none; }
.gal__menu a.gal__here { opacity: 0.45; pointer-events: none; }
.gal__caret { font-size: 9px; opacity: 0.7; }

@media (max-width: 700px) {
  .bar__name { font-size: 13px; }
  .portals { gap: 8px; }
}
