/* The front door: Cinderrealm's login page (login.js). Iron-and-stone panels, gold on dark,
   embers rising behind. Every class here starts with fd- so nothing touches the game's own
   styles. Fonts: Cinzel and Cinzel Decorative (SIL OFL 1.1), served with the game. */

@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 400; font-display: swap; src: url('login/fonts/cinzel-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 600; font-display: swap; src: url('login/fonts/cinzel-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 700; font-display: swap; src: url('login/fonts/cinzel-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 900; font-display: swap; src: url('login/fonts/cinzel-latin-900-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel Decorative'; font-style: normal; font-weight: 700; font-display: swap; src: url('login/fonts/cinzel-decorative-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel Decorative'; font-style: normal; font-weight: 900; font-display: swap; src: url('login/fonts/cinzel-decorative-latin-900-normal.woff2') format('woff2'); }

.fd {
  --fd-gold-bright: #f0c352;
  --fd-gold-mid: #c89528;
  --fd-gold-dark: #7a5410;
  --fd-ember-red: #d3381a;
  --fd-ember-orange: #f86a21;
  --fd-bg: #070504;
  --fd-panel-bg: rgba(16, 12, 10, 0.88);
  --fd-panel-border: #3d2c1d;
  --fd-text: #e8dbce;
  --fd-muted: #8c7a6b;
  --fd-font-title: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --fd-font-body: 'Cinzel', Georgia, 'Times New Roman', serif;
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  touch-action: pan-y;   /* the game's body takes no touch gestures; the front door may scroll on phones */
  background: var(--fd-bg);
  font-family: var(--fd-font-body);
  color: var(--fd-text);
  user-select: none;
  -webkit-user-select: none;
}
.fd.hidden { display: none; }
/* The game's buttons are bevelled stone (style.css); the front door's draw themselves. */
:where(.fd) button {
  background: none; border: none; border-radius: 0; margin: 0; color: inherit;
  text-shadow: none; box-shadow: none; font-weight: inherit; transform: none;
}
.fd-tab:hover, .fd-close:hover { background: none; }
.fd-tab:active, .fd-close:active, .fd-icon-btn:active { transform: none; box-shadow: none; }
.fd *, .fd *::before, .fd *::after { box-sizing: border-box; }
.fd input { user-select: text; -webkit-user-select: text; }

/* Embers, vignette and the glow along the bottom */
.fd-embers { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; display: block; }
.fd-vignette {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(circle at center, transparent 30%, rgba(3, 2, 2, 0.85) 80%, rgba(0, 0, 0, 0.98) 100%);
}
.fd-glow {
  position: absolute; bottom: -100px; left: 50%; transform: translateX(-50%);
  width: 80%; height: 300px; z-index: 2; pointer-events: none; filter: blur(40px);
  background: radial-gradient(ellipse at bottom, rgba(211, 56, 26, 0.25) 0%, rgba(248, 106, 33, 0.1) 40%, transparent 70%);
}

/* Top bar: build badge, then Patch Chronicles, theme music and settings */
.fd-top {
  position: absolute; top: 20px; left: 0; right: 0; padding: 0 30px; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
}
.fd-badge {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  background: rgba(20, 15, 12, 0.8); border: 1px solid var(--fd-panel-border); border-radius: 4px;
  font-size: 0.75rem; letter-spacing: 1.5px; color: var(--fd-gold-mid); text-transform: uppercase;
}
.fd-badge svg { width: 14px; height: 14px; fill: var(--fd-gold-mid); }
.fd-utils { display: flex; gap: 12px; }
.fd-icon-btn {
  width: 38px; height: 38px; padding: 0;
  background: rgba(20, 15, 12, 0.8); border: 1px solid var(--fd-panel-border); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--fd-gold-mid); transition: all 0.2s ease;
}
.fd-icon-btn:hover, .fd-icon-btn:focus-visible {
  border-color: var(--fd-gold-bright); color: var(--fd-gold-bright);
  box-shadow: 0 0 10px rgba(240, 195, 82, 0.2); outline: none;
}
.fd-icon-btn[aria-pressed="false"] { color: var(--fd-muted); }
.fd-icon-btn .fd-off { display: none; }
.fd-icon-btn[aria-pressed="false"] .fd-on { display: none; }
.fd-icon-btn[aria-pressed="false"] .fd-off { display: inline; }

/* The centre: logo, then the card */
.fd-main {
  position: relative; z-index: 5; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
.fd-title { margin-bottom: 25px; text-align: center; }
.fd-logo {
  display: block; width: min(360px, 82vw); height: auto;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 24px rgba(240, 195, 82, 0.15));
}
.fd-card {
  width: 100%; max-width: 420px; padding: 28px; position: relative;
  background: var(--fd-panel-bg); border: 1px solid var(--fd-panel-border); border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), inset 0 0 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(200, 149, 40, 0.1);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.fd-corner { position: absolute; width: 12px; height: 12px; border-color: var(--fd-gold-mid); border-style: solid; pointer-events: none; }
.fd-corner.tl { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.fd-corner.tr { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.fd-corner.bl { bottom: -1px; left: -1px; border-width: 0 0 2px 2px; }
.fd-corner.br { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

/* Tabs */
.fd-tabs { display: flex; border-bottom: 1px solid var(--fd-panel-border); margin-bottom: 22px; }
.fd-tab {
  flex: 1; padding: 10px; background: none; border: none; cursor: pointer; position: relative;
  color: var(--fd-muted); font-family: var(--fd-font-body); font-weight: 700; font-size: 0.9rem;
  text-transform: uppercase; letter-spacing: 1px; transition: all 0.2s ease;
}
.fd-tab:focus-visible { outline: 1px dotted var(--fd-gold-mid); outline-offset: -4px; }
.fd-tab.active { color: var(--fd-gold-bright); }
.fd-tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--fd-gold-bright), transparent);
}

/* Fields */
.fd-group { margin-bottom: 18px; }
.fd-label {
  display: block; margin-bottom: 6px; font-size: 0.75rem; letter-spacing: 1.5px; font-weight: 700;
  color: var(--fd-gold-mid); text-transform: uppercase;
}
.fd-input-wrap { position: relative; display: flex; align-items: center; }
.fd-input-icon { position: absolute; left: 12px; width: 16px; height: 16px; fill: var(--fd-muted); transition: fill 0.2s; pointer-events: none; }
.fd-input {
  width: 100%; padding: 12px 12px 12px 38px; outline: none;
  background: rgba(8, 6, 5, 0.8); border: 1px solid #2a1f15; border-radius: 4px;
  color: var(--fd-text); font-family: var(--fd-font-body); font-size: 0.95rem; transition: all 0.2s ease;
}
.fd-input::placeholder { color: #5e5045; }
.fd-input:focus { border-color: var(--fd-gold-mid); box-shadow: 0 0 10px rgba(200, 149, 40, 0.2); }
.fd-input:focus ~ .fd-input-icon { fill: var(--fd-gold-bright); }

/* The server card: live status, players online, ping and load */
.fd-server {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 18px; padding: 10px 14px;
  background: rgba(10, 8, 7, 0.6); border: 1px solid var(--fd-panel-border); border-radius: 4px;
}
.fd-server-info { display: flex; align-items: center; gap: 10px; }
.fd-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--fd-muted); box-shadow: 0 0 8px var(--fd-muted); }
.fd-server[data-state="online"] .fd-dot { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.fd-server[data-state="down"] .fd-dot { background: var(--fd-ember-red); box-shadow: 0 0 8px var(--fd-ember-red); }
.fd-server-name { font-size: 0.85rem; font-weight: 700; color: var(--fd-text); }
.fd-server-meta { font-size: 0.7rem; color: var(--fd-muted); }
.fd-server[data-state="online"] #fd-status { color: #22c55e; }
.fd-server[data-state="down"] #fd-status { color: var(--fd-ember-red); }
.fd-load {
  flex: none; font-size: 0.65rem; padding: 2px 6px; border-radius: 3px; font-weight: 700; letter-spacing: 0.5px;
  background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.4); color: #86efac;
}
.fd-load:empty { display: none; }
.fd-load[data-load="busy"] { background: rgba(202, 138, 4, 0.15); border-color: rgba(234, 179, 8, 0.45); color: #fde047; }
.fd-load[data-load="high"] { background: rgba(180, 83, 9, 0.2); border-color: rgba(217, 119, 6, 0.4); color: #fbbf24; }

/* Messages under the server card */
.fd-msg {
  margin-bottom: 14px; padding: 10px 12px; border-radius: 4px; font-size: 0.8rem; line-height: 1.4;
  background: rgba(211, 56, 26, 0.12); border: 1px solid rgba(211, 56, 26, 0.5); color: #f0a08a;
}
.fd-msg:empty { display: none; }
.fd-msg.ok { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.45); color: #9fe6b8; }
.fd-msg.info { background: rgba(200, 149, 40, 0.08); border-color: rgba(200, 149, 40, 0.4); color: #e8d29a; }

/* Remember me, then the big button */
.fd-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; font-size: 0.8rem; }
.fd-remember { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--fd-muted); }
.fd-remember input { accent-color: var(--fd-gold-mid); width: 15px; height: 15px; }
.fd-submit {
  width: 100%; padding: 14px; cursor: pointer;
  background: linear-gradient(180deg, #8a1f11 0%, #521006 100%);
  border: 1px solid var(--fd-ember-red); border-radius: 4px; color: #fff;
  font-family: var(--fd-font-body); font-weight: 900; font-size: 1.05rem; letter-spacing: 2px; text-transform: uppercase;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease; display: flex; align-items: center; justify-content: center;
}
.fd-submit:hover:not(:disabled), .fd-submit:focus-visible {
  background: linear-gradient(180deg, #a82717 0%, #691508 100%); border-color: var(--fd-ember-orange); outline: none;
  box-shadow: 0 0 20px rgba(248, 106, 33, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3); transform: translateY(-1px);
}
.fd-submit:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); }
.fd-submit:disabled { opacity: 0.6; cursor: default; }

/* Bottom bar */
.fd-bottom {
  position: absolute; bottom: 20px; left: 0; right: 0; padding: 0 30px; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--fd-muted);
}
.fd-gold { color: var(--fd-gold-mid); }

/* Drawers: Patch Chronicles and Settings slide in from the right */
.fd-drawer {
  position: fixed; top: 0; right: -400px; width: 380px; height: 100%; z-index: 100; padding: 30px;
  overflow-y: auto; visibility: hidden;
  background: rgba(12, 9, 8, 0.95); border-left: 1px solid var(--fd-panel-border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.3s;
}
.fd-drawer.open { right: 0; visibility: visible; transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s; }
.fd-drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--fd-panel-border);
}
.fd-drawer-title { margin: 0; font-family: var(--fd-font-title); color: var(--fd-gold-bright); font-size: 1.1rem; }
.fd-close { background: none; border: none; color: var(--fd-muted); cursor: pointer; font-size: 1.4rem; line-height: 1; padding: 2px 6px; }
.fd-close:hover, .fd-close:focus-visible { color: var(--fd-gold-bright); outline: none; }
.fd-news-item { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px dashed rgba(61, 44, 29, 0.5); }
.fd-news-date { font-size: 0.7rem; color: var(--fd-gold-dark); margin-bottom: 4px; letter-spacing: 1px; }
.fd-news-title { font-size: 0.9rem; color: var(--fd-gold-mid); font-weight: 700; margin-bottom: 6px; }
.fd-news-tag {
  display: inline-block; margin-left: 8px; padding: 1px 6px; vertical-align: 2px; border-radius: 3px;
  font-size: 0.6rem; letter-spacing: 1px; text-transform: uppercase;
  background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.4); color: #86efac;
}
.fd-news-body { font-size: 0.8rem; color: var(--fd-muted); line-height: 1.4; }
.fd-setting {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px dashed rgba(61, 44, 29, 0.5); font-size: 0.85rem; cursor: pointer;
}
.fd-setting input[type="checkbox"] { accent-color: var(--fd-gold-mid); width: 16px; height: 16px; }
.fd-setting input[type="range"] { accent-color: var(--fd-gold-mid); width: 140px; }
.fd-setting-note { margin-top: 14px; font-size: 0.72rem; color: var(--fd-muted); line-height: 1.5; }

/* Small screens: the page scrolls instead of overlapping */
@media (max-width: 640px) {
  .fd { overflow-y: auto; }
  .fd-top { padding: 0 12px; top: 10px; }
  .fd-badge { font-size: 0.6rem; padding: 5px 9px; letter-spacing: 1px; gap: 6px; }
  .fd-utils { gap: 8px; }
  .fd-icon-btn { width: 32px; height: 32px; }
  .fd-main { justify-content: flex-start; height: auto; min-height: 100%; padding: 84px 16px 110px; }
  .fd-title { margin-bottom: 12px; }
  .fd-logo { width: min(230px, 68vw); }
  .fd-card { padding: 20px; }
  .fd-embers, .fd-vignette { position: fixed; }
  .fd-bottom {
    position: fixed; bottom: 0; padding: 8px 12px; font-size: 0.62rem;
    background: rgba(7, 5, 4, 0.9); border-top: 1px solid var(--fd-panel-border);
  }
  .fd-drawer { width: min(380px, 94vw); padding: 22px; }
}
@media (max-height: 640px) and (min-width: 641px) {
  .fd { overflow-y: auto; }
  .fd-main { justify-content: flex-start; height: auto; min-height: 100%; padding: 70px 20px 70px; }
  .fd-logo { width: min(260px, 60vw); }
  .fd-title { margin-bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .fd-drawer, .fd-drawer.open, .fd-submit, .fd-icon-btn { transition: none; }
}
