/* Basis-Styling für "Die letzte Dynastie" Prototyp */
:root {
  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-heading: 'Cinzel', 'EB Garamond', Georgia, serif;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: #f4efe8;
  background-image: url('../img/parchment.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #333;
}

h1, h2, h3 {
  font-family: var(--font-heading);
}

/* Subtile typografische Verfeinerungen für Überschriften */
h1 {
  letter-spacing: 0.04em;
  line-height: 1.1;
  font-weight: 700;
}
h2 {
  letter-spacing: 0.03em;
  line-height: 1.15;
  font-weight: 700;
}
h3 {
  letter-spacing: 0.02em;
  line-height: 1.2;
  font-weight: 400;
}

#game-container {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding: 20px;
}

header {
  margin-bottom: 20px;
}
/* Seasonal banner area (keeps 16:9 on all screens) */
#title-banner.banner-wrap {
  width: 100%;
  aspect-ratio: 16 / 9; /* default (mobile-first) */
  /* Clamp the height so it never gets too small or too large */
  min-height: 160px;
  max-height: 420px;
  overflow: hidden;
  margin-bottom: 10px;
}
#title-banner img#title-image {
  width: 100%;
  height: 100%;
  object-fit: cover; /* seasonal images should be 16:9; minimal crop otherwise */
  object-position: center;
  display: block;
}

/* On larger screens, reduce banner height to ~65% of the 16:9 height */
@media (min-width: 992px) {
  #title-banner.banner-wrap {
    /* 16:9 height is 56.25% of width; 65% of that ≈ 36.5625% */
    aspect-ratio: 100 / 36.5625;
    max-height: 380px;
  }
  /* Horizontally squash the banner image by 20% on desktop */
  #title-banner img#title-image {
    /* Vertically squash content by ~20% while keeping fill */
    width: 100%;
    height: 125%;            /* compensate scaleY(0.8) => 1/0.8 = 1.25 */
    margin: 0;               /* avoid crop from margin-top with percent semantics */
    object-fit: cover;       /* keep banner filled */
    object-position: center top; /* bias to show more sky */
    transform: scaleY(0.8);
    transform-origin: top center; /* anchor at top */
  }
}
header h1 {
  margin: 0;
  font-size: 2.4rem;
  color: #5a3e18;
  font-family: var(--font-heading);
}
header #month-counter {
  margin: 4px 0 0;
  font-size: 1rem;
  color: #5a3e18;
}
/* Day progress bar under the month counter */
#day-progress.day-progress {
  width: 100%;
  max-width: 420px;
  height: 6px;
  margin: 6px auto 0;
  background: rgba(90, 62, 24, 0.15);
  border-radius: 999px;
  overflow: hidden;
}
#day-progress .bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #835c32, #b0895a);
  transition: width 180ms ease-out;
}

main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Gemeinsames Layout für Provinzlisten (Spieler und Vasallen) */
.provinces {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-bottom: 20px;
}

.province-card {
  flex: 1 1 280px;
  min-width: 250px;
  position: relative;
}

/* Spieler-Karte hervorheben */
.province-card.player-card {
  border: 2px solid #835c32;
}

/* Frame sprite integration (2x2 sprite sheets: TL, TR, BL, BR) */
/* Canvas-rendered frame overlay (nine-slice, no stretching) */
.province-card .frame-overlay {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
  z-index: 0;
}
.province-card > * { position: relative; z-index: 1; }
.province-card h2 {
  margin-top: 0;
  font-size: 1.4rem;
  color: #5a3e18;
  font-family: var(--font-heading);
}
.province-header { margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.header-right { display: inline-flex; align-items: center; gap: 6px; }
.crest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #e9d9c6;
  color: #5a3e18;
  font-weight: 700;
  border: 1px solid rgba(90,62,24,0.3);
}
.crest-img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(90,62,24,0.3);
}
.role-badge {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(90, 62, 24, 0.12);
  color: #5a3e18;
  font-size: 0.8rem;
}
.emblem.ai {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #5a3e18;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Province stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
  align-items: start;
}
.stat-row { display: flex; align-items: center; gap: 8px; }
.stat .meter {
  height: 6px;
  background: rgba(90, 62, 24, 0.15);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.stat .meter .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #835c32, #b0895a);
  transition: width 180ms ease-out;
}
.stat .meter.morale .bar { background: #3a9d23; }
.stat .meter.morale .bar.med { background: #d9a321; }
.stat .meter.morale .bar.low { background: #b44; }
.stat .subline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  flex-wrap: nowrap;
}
.stat .hint {
  font-size: 0.85rem;
  color: rgba(90,62,24,0.9);
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;               /* enable ellipsis */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note.cap { font-size: 0.8rem; color: #a34; margin-top: 0; white-space: nowrap; }
/* Gold prediction: nudge down by 10px to align with rows that include a meter */
.gold-stat .subline { margin-top: 12px; }
/* Reserve space on stats without a cap note so rows align nicely */
.cap-spacer { visibility: hidden; min-width: 6ch; height: 1em; }
@media (max-width: 768px) {
  .stats-grid { gap: 8px 10px; }
  .stat .hint { font-size: 0.8rem; }
}

/* Per-card icon tinting */
.player-card .icon { color: #835c32; }
.ai-card .icon { color: #5a3e18; }
.province-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.95rem;
}
.province-card li {
  margin: 4px 0;
}

/* Icon utilities for stat lists */
.icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  vertical-align: -4px;
  margin-right: 6px;
  background-color: currentColor; /* Tint to text color */
  /* Use PNG alpha as mask, color via background-color */
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  opacity: 0.95;
}

/* Icon masks (use small PNGs as alpha masks) */
.icon-food    { -webkit-mask-image: url('../img/icons/small/food.png');    mask-image: url('../img/icons/small/food.png'); }
.icon-gold    { -webkit-mask-image: url('../img/icons/small/gold.png');    mask-image: url('../img/icons/small/gold.png'); }
.icon-morale  { -webkit-mask-image: url('../img/icons/small/morale.png');  mask-image: url('../img/icons/small/morale.png'); }
.icon-troops  { -webkit-mask-image: url('../img/icons/small/troops.png');  mask-image: url('../img/icons/small/troops.png'); }
.icon-workers { -webkit-mask-image: url('../img/icons/small/workers.png'); mask-image: url('../img/icons/small/workers.png'); }
.stats-list li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.panel.hidden {
  display: none;
}
.panel h2 {
  margin-top: 0;
  color: #5a3e18;
  font-family: var(--font-heading);
  border-bottom: 1px solid rgba(90, 62, 24, 0.2);
  padding-bottom: 6px;
  margin-bottom: 12px;
}

/* Unter-Überschriften im Build-Panel */
#build-panel h3 {
  margin: 12px 0 4px;
  font-size: 1.1rem;
  color: #5a3e18;
  font-family: var(--font-heading);
}

.options {
  margin-top: 10px;
}

/* Generic options list styles */
.options-list .btn {
  text-align: left;
}
.options-list .btn:disabled,
.options .btn:disabled,
.options-list .btn[aria-disabled="true"],
.options .btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  color: #7a6a56;
  box-shadow: none !important;
  filter: none;
}
.options-list .btn:disabled .icon,
.options .btn:disabled .icon,
.options-list .btn[aria-disabled="true"] .icon,
.options .btn[aria-disabled="true"] .icon {
  opacity: 0.6;
  filter: grayscale(100%);
}

/* Building tags */
.badges { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(90, 62, 24, 0.12);
  color: #5a3e18;
  font-size: 0.85rem;
}

footer {
  text-align: center;
  margin-top: 20px;
  color: #5a3e18;
  font-size: 0.8rem;
}

/* Run availability badges */
.run-availability { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.run-availability .ability-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(90, 62, 24, 0.12);
  color: #5a3e18;
  font-size: 0.85rem;
  border: 1px solid rgba(90,62,24,0.2);
}
.run-availability .ability-icon { width: 16px; height: 16px; display: inline-block; background-color: currentColor; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
/* Placeholder icons using existing masks where it fits */
.run-availability .icon-seal { -webkit-mask-image: url('../img/icons/small/gold.png'); mask-image: url('../img/icons/small/gold.png'); }
.run-availability .icon-intel { -webkit-mask-image: url('../img/icons/small/morale.png'); mask-image: url('../img/icons/small/morale.png'); }
.run-availability .icon-diplomacy { -webkit-mask-image: url('../img/icons/small/workers.png'); mask-image: url('../img/icons/small/workers.png'); }

/* Mobile-Layout-Anpassungen */
@media (max-width: 768px) {
  main {
    display: flex;
    flex-direction: column;
  }
  /* Reihenfolge anpassen: Spielerprovince → Ereignis → Bau/Rekrut → Vasallen */
  #player-province {
    order: 1;
  }
  #event-panel {
    order: 2;
  }
  #build-panel {
    order: 3;
  }
  #ai-provinces {
    order: 4;
  }
  .provinces {
    flex-direction: column;
    align-items: stretch;
  }
  .province-card {
    width: 100%;
    flex: none;
  }
}
