/**
 * Intermarché Fuel Price Display System
 * Official Vertical Totem Display Stylesheet
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-outer: #99080e;
  --bg-main: #c90c14;
  --frame-border: #ffffff;
  --header-text: #ffffff;
}

body.theme-totem {
  --bg-outer: #d4d4d8;
  --bg-main: #f4f4f6;
  --frame-border: #c90c14;
  --header-text: #111111;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg-outer);
  font-family: 'Montserrat', Arial, sans-serif;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease;
}

.totem-shell {
  width: 100%;
  height: 100%;
  max-width: 100%;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(8px, 1.8dvh, 22px) clamp(8px, 2.5vw, 28px);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
}

@media (min-aspect-ratio: 10/9) {
  body:not(.wide-stretch) .totem-shell {
    max-width: min(92vw, calc(100dvh * 0.78));
    border-left: 3px solid rgba(255, 255, 255, 0.25);
    border-right: 3px solid rgba(255, 255, 255, 0.25);
  }
}

/* 1. Header Area with New Official Intermarché Logo */
.top-header-area {
  width: 100%;
  height: 15%;
  min-height: 64px;
  max-height: 145px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: clamp(4px, 1dvh, 10px) clamp(6px, 1.6vw, 16px);
  flex-shrink: 0;
}

.logo-box {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.brand-logo-img {
  max-width: 96%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: clamp(3px, 0.5vw, 6px);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28);
}

/* 2. Main Totem Board Frame */
.vertical-board-frame {
  width: 100%;
  height: 84%;
  border: clamp(3px, 0.55dvh, 7px) solid var(--frame-border);
  background-color: rgba(0, 0, 0, 0.14);
  padding: clamp(6px, 1.2dvh, 18px) clamp(6px, 1.6vw, 22px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(6px, 1.2dvh, 16px);
  flex: 1;
  min-height: 0;
}

/* 3. Fuel Row: 3 Columns (Badge 32%, Divider 1.6%, Digital Box with clustered Unit 66.4%) */
.fuel-row {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 32% 1.6% 66.4%;
  align-items: stretch;
  background-color: #050505;
  border: clamp(1.5px, 0.25dvh, 3px) solid rgba(255, 255, 255, 0.88);
  border-radius: 6px;
  overflow: hidden;
}

/* Fuel Badges */
.fuel-badge {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 4px clamp(6px, 1.6vw, 18px);
  font-weight: 800;
  position: relative;
  overflow: hidden;
}
.badge-black {
  background-color: #0b0b0b;
  color: #ffffff;
}
.badge-yellow {
  background-color: #f3c600;
  color: #080808;
}
.badge-darkgreen {
  background-color: #084c24;
  color: #ffffff;
}
.badge-green {
  background-color: #128732;
  color: #ffffff;
}

.fuel-name-line1 {
  font-size: clamp(12px, min(3.5vw, 2.9dvh), 34px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.fuel-name-line2 {
  font-size: clamp(11px, min(3.2vw, 2.6dvh), 31px);
  line-height: 1.12;
  font-weight: 800;
  white-space: nowrap;
}
.octane-tag {
  position: absolute;
  right: clamp(4px, 1vw, 14px);
  bottom: clamp(3px, 0.8dvh, 10px);
  font-size: clamp(13px, min(3.8vw, 3.3dvh), 38px);
  font-weight: 900;
  line-height: 1;
  opacity: 0.95;
}

.divider-wrap {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #050505;
}
.divider-line {
  width: clamp(2px, 0.4dvh, 5px);
  height: 80%;
  background-color: #ffffff;
  border-radius: 2px;
}

/* Digital LED Price Display Box: Center Aligned with Balanced Clean Margins */
.digital-box {
  width: 100%;
  height: 100%;
  background-color: #050505;
  display: flex;
  align-items: center; /* Digits vertically in the CENTER */
  justify-content: center; /* Horizontally in the CENTER */
  position: relative;
  overflow: hidden;
  padding: 0; /* Dynamic responsive safe margins enforced in JS */
  box-sizing: border-box;
}

/* Cluster keeping Digits Centered and Unit at the bottom on the exact same line */
.price-display-cluster {
  display: inline-flex;
  align-items: flex-end; /* €/L sits on the exact bottom line as the digits */
  justify-content: center;
  position: relative;
  line-height: 1;
  box-sizing: border-box;
}

.digits-wrapper {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
}

.digits-ghost {
  font-family: 'DSEG7-Classic', monospace;
  font-weight: bold;
  font-style: normal;
  letter-spacing: 0.02em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  display: inline-block;
  user-select: none;
}

.digits-active {
  font-family: 'DSEG7-Classic', monospace;
  font-weight: bold;
  font-style: normal;
  letter-spacing: 0.02em;
  line-height: 1;
  color: #ffffff;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  z-index: 2;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  transition: color 0.2s ease;
}

body.theme-totem .digits-active {
  color: #ffca57;
  text-shadow: 0 0 12px rgba(255, 190, 60, 0.45);
}

/* Unit Label: €/L is at bottom on the exact same line of the digit */
.unit-label {
  color: #ffffff;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 800;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  align-self: flex-end;
  margin-left: clamp(3px, 0.6vw, 8px);
  margin-bottom: 0.04em; /* Aligns baseline directly with bottom segment of 7-segment digits */
  flex-shrink: 0; /* FORBIDDEN from shrinking or clipping */
}

@media (max-width: 380px) {
  .fuel-row {
    grid-template-columns: 33% 1.5% 65.5%;
  }
  .octane-tag {
    font-size: 11px;
    right: 3px;
    bottom: 2px;
  }
}

@media (max-height: 480px) {
  .top-header-area {
    height: 15%;
    min-height: 48px;
  }
  .vertical-board-frame {
    height: 83%;
    padding: 4px 8px;
    gap: 4px;
  }
}

.top-controls {
  position: fixed;
  top: 10px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  z-index: 999;
  transition: opacity 0.4s ease;
  max-width: 95vw;
}
.top-controls.hidden {
  opacity: 0;
  pointer-events: none;
}
.ctrl-btn {
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 4px;
}

.sched-indicator {
  background: rgba(245, 158, 11, 0.9);
  color: #000;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  display: none;
}
.sched-indicator.active {
  display: inline-block;
}
