/* Global fonts */
@font-face {
  font-family: "SevenSegment";
  src: url("/fonts/Seven-Segment.woff2") format("woff2"),
       url("/fonts/Seven-Segment.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "DSEG7Classic";
  src: url("/fonts/DSEG7Classic-Regular.woff") format("woff"),
       url("/fonts/DSEG7Classic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --nav-h: 92px; 
  --bg: #1f2027;
  --text: #e8e8ee;
  --muted: #a9acb8;
  --line: rgba(255,255,255,.10);
  --accent: #28f07a;
  --ui-font: "Inter", system-ui, -apple-system, sans-serif;
  --bit-font: "SevenSegment", monospace;
  --num-font:  "DSEG7Classic"
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--ui-font); display: flex; flex-direction: column; }

/* --- BASE LAYOUT --- */
.siteNav { position: sticky; top: 0; z-index: 50; height: var(--nav-h); background: rgba(0,0,0,.10); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); margin-bottom: 25px; }
.navInner { height: 90px; max-width: 1400px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brandLogo { width: 75px; height: 75px; image-rendering: pixelated; }
.brandName { letter-spacing: .12em; font-weight: 900; font-size: 18px; }
.navLinks { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.navLinks a { color: var(--muted); text-decoration: none; font-weight: 800; letter-spacing: .12em; font-size: 16px; }
.navLinks a:hover, .navLinks a.active { color: #e8e8ee; } 

.pageWrap { flex: 1; max-width: 1400px; margin: 0 auto; padding: 0 20px 40px; width: 100%; display: flex; flex-direction: column; }
.siteFooter { border-top: 1px solid var(--line); background: rgba(0,0,0,.08); }
.footerInner { max-width: 1400px; margin: 0 auto; padding: 18px 20px; color: var(--muted); font-size: 12px; letter-spacing: .08em; display: flex; flex-direction: column; gap: 6px; }

/* --- APP LAYOUT --- */
.binaryPage {
  --toolbox-w: 360px;
  --toolbox-gap: 22px;
  --toolbox-toggle-top: calc(var(--nav-h) + 16px);
  --toolbox-top: calc(var(--toolbox-toggle-top) + 60px);
  position: relative; padding-top: 16px; flex: 1; display: flex; flex-direction: column;
}
.binaryPage:not(.toolboxCollapsed) { padding-right: calc(var(--toolbox-w) + var(--toolbox-gap)); }
.binaryPage.toolboxCollapsed { padding-right: 0; }
.topGrid { display: flex; align-items: stretch; gap: 28px; flex: 1; }
.leftCol { flex: 1 1 auto; min-width: 0; container-type: inline-size; display: flex; flex-direction: column; }

/* --- READOUT FORMATTING --- */
.readoutContainer { display: flex; align-items: center; justify-content: center; gap: 64px; width: 100%; }
.readout { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 4px; }
.readoutBlock { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.label { font-family: var(--bit-font); letter-spacing: .14em; text-transform: uppercase; font-size: 18px; opacity: .75; margin: 0; }
.num { font-family: var(--num-font); color: #28f07a; text-shadow: 0 0 18px rgba(40,240,122,.35); letter-spacing: 2px; }

.denaryValue, .hexValue, .binaryValue { display: flex; gap: 16px; justify-content: center; white-space: pre-wrap; text-align: center; margin: 0; line-height: 1; }
.denaryValue { font-size: 56px; }
.hexValue { font-size: 48px; }
.binaryValue { font-size: 40px; }
.divider { height: 1px; background: rgba(255,255,255,.08); margin: 16px 0 16px; }

/* --- GRIDS & BITS --- */
.bitsWrap { width: 100%; }
.bitsGrid { --cols: 8; display: grid; grid-template-columns: repeat(var(--cols), minmax(92px, 1fr)); gap: 26px 22px; align-items: start; justify-items: center; }
.bitsGrid.bitsFew { justify-content: center; }
.bit { width: 100%; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 8px; container-type: inline-size; }
.bitVal { font-family: var(--bit-font); font-size: min(32px, calc(140cqw / var(--len, 1))); letter-spacing: 2px; color: rgba(232,232,238,.85); white-space: nowrap; line-height: 1; }

.bulb { width: 44px; height: 44px; color: rgba(255,255,255,.15); margin-bottom: 8px; flex-shrink: 0; transition: 0.2s ease; background: transparent; display: flex; align-items: center; justify-content: center; }
.bulb svg { width: 100%; height: 100%; display: block; }
.bulb.on { color: #ffd86b !important; filter: drop-shadow(0 0 14px rgba(255, 216, 107, 1)) !important; }
.bulb.on svg { fill: #ffd86b !important; }

.switch { position: relative; width: 56px; height: 28px; display: inline-block; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.14); border-radius: 999px; transition: .2s ease; }
.slider::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 2px; background: rgba(255,255,255,.92); border-radius: 999px; transition: .2s ease; pointer-events: none; }
.switch input:checked + .slider { background: rgba(40,240,122,.30); border-color: rgba(40,240,122,.30); }
.switch input:checked + .slider::before { transform: translateX(28px); }

/* --- HEXADECIMAL --- */
.hexGrid { --cols: 4; display: grid; grid-template-columns: repeat(var(--cols), minmax(160px, 1fr)); gap: 32px 20px; align-items: start; justify-items: center; width: 100%; }
.hexGrid.bitsFew { justify-content: center; }
.hexCol { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* --- HEX COLOURS SPECIFIC --- */
.colorGroupWrap { display: flex; flex-wrap: nowrap; gap: 16px; justify-content: center; width: 100%; }
.colorGroup { display: flex; gap: 12px; padding: 12px; background: rgba(255,255,255,.02); border-radius: 20px; border: 1px solid rgba(255,255,255,.05); flex: 0 1 auto; min-width: 0; }
.colorPreviewSide { display: flex; gap: 24px; align-items: center; justify-content: center; }
.colorBoxWrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.colorBox { width: 60px; height: 60px; border-radius: 12px; border: 2px solid rgba(255,255,255,.15); box-shadow: 0 4px 16px rgba(0,0,0,.4); background-color: #000000; transition: background-color 0.2s ease; }
.colorBoxLabel { font-family: var(--ui-font); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.text-red { color: #ff5555 !important; text-shadow: 0 0 18px rgba(255,85,85,.35) !important; }
.text-green { color: #28f07a !important; text-shadow: 0 0 18px rgba(40,240,122,.35) !important; }
.text-blue { color: #55aaff !important; text-shadow: 0 0 18px rgba(85,170,255,.35) !important; }

/* HEX CARD */
.hexCard { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 190px; flex: 0 1 auto; min-width: 0; box-shadow: 0 4px 24px rgba(0,0,0,.2); backdrop-filter: blur(10px); }
.hexCardButtons { display: flex; gap: 10px; }
.hexCardBtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); font-family: var(--bit-font); font-size: 16px; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; color: rgba(232,232,238,.92); transition: all 0.2s ease; }
.hexCardBtn.inc { background: rgba(40,240,122,.15); border-color: rgba(40,240,122,.25); }
.hexCardBtn.inc:hover { background: rgba(40,240,122,.25); border-color: rgba(40,240,122,.4); }
.hexCardBtn.dec { background: rgba(255,80,80,.18); border-color: rgba(255,80,80,.25); }
.hexCardBtn.dec:hover { background: rgba(255,80,80,.28); border-color: rgba(255,80,80,.4); }
.hexDigitDisplay { font-family: var(--num-font); font-size: 48px; color: #28f07a; text-shadow: 0 0 18px rgba(40,240,122,.35); line-height: 1; }
.hexNibbleRow { display: flex; gap: 10px; justify-content: center; width: 100%; }
.hexNibbleBit { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hexNibbleBulb { width: 32px !important; height: 32px !important; margin-bottom: 2px !important; }
.hexNibbleLabel { font-family: var(--bit-font); font-size: 24px; color: rgba(232,232,238,.6); }
.hexColWeight { font-family: var(--bit-font); font-size: 40px; color: rgba(232,232,238,.6); margin-top: 14px; }


/* --- TOOLBOX --- */
.toolboxToggle { position: fixed; top: var(--toolbox-toggle-top); right: 22px; z-index: 90; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.15); backdrop-filter: blur(8px); color: rgba(232,232,238,.95); font-family: var(--bit-font); font-weight: 800; font-size: 16px; letter-spacing: .12em; text-transform: uppercase; cursor: pointer; }
.toolboxIcon { font-size: 20px; filter: drop-shadow(0 0 8px rgba(255,105,180,.35)); }
.toolboxToggle:hover { border-color: rgba(255,255,255,.22); }
.panelCol { position: fixed; top: var(--toolbox-top); right: 22px; width: var(--toolbox-w); z-index: 80; display: flex; flex-direction: column; gap: 16px; transform: translateX(0); opacity: 1; transition: transform 420ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease; }
.binaryPage.toolboxCollapsed .panelCol { transform: translateX(calc(var(--toolbox-w) + 32px)); opacity: 0; pointer-events: none; }
.card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.10); border-radius: 16px; padding: 16px; backdrop-filter: blur(10px); }
.cardTitle { font-family: var(--bit-font); font-weight: 900; letter-spacing: .14em; text-transform: uppercase; font-size: 18px; color: rgba(232,232,238,.9); margin-bottom: 12px; }
.hint { font-family: var(--bit-font); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: rgba(232,232,238,.55); margin-top: 10px; line-height: 1.35; }
.toggleRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggleLabel { font-family: var(--bit-font); font-size: 16px; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; color: var(--muted); transition: color 0.2s, text-shadow 0.2s; }
.toggleLabel.activeMode { color: #28f07a; text-shadow: 0 0 12px rgba(40,240,122,.45); }
.subCard { margin-top: 12px; padding: 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,.10); background: rgba(0,0,0,.12); }
.subTitle { font-family: var(--bit-font); font-weight: 900; letter-spacing: .14em; text-transform: uppercase; font-size: 16px; margin-bottom: 10px; opacity: .85; }
.bitWidthRow { display: flex; align-items: center; gap: 10px; }
.miniBtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: rgba(232,232,238,.9); font-family: var(--bit-font); font-weight: 900; font-size: 22px; cursor: pointer; }
.miniBtn:hover { border-color: rgba(255,255,255,.22); }
.bitInputWrap { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: 12px; border: 1px solid rgba(255,255,255,.10); background: rgba(255,255,255,.04); padding: 10px 12px; }
.bitInputLabel { font-family: var(--bit-font); font-size: 16px; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.bitInput { width: 70px; text-align: right; font-family: var(--num-font); font-size: 28px; letter-spacing: 2px; color: #28f07a; background: transparent; border: none; outline: none; }
.btn { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: rgba(232,232,238,.92); border-radius: 12px; padding: 10px 12px; font-family: var(--bit-font); font-size: 14px; letter-spacing: .12em; text-transform: uppercase; font-weight: 900; cursor: pointer; }
.btn:hover { border-color: rgba(255,255,255,.22); }
.btnAccent { background: rgba(40,240,122,.12); border-color: rgba(40,240,122,.22); }
.btnAccent:hover { border-color: rgba(40,240,122,.35); }
.btnHalf { width: calc(50% - 6px); }
.btnWide { width: 100%; }
.controlsRow { display: flex; gap: 12px; margin-bottom: 12px; }
.toolRowCentered { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.toolBtn { width: 46px; height: 46px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: rgba(232,232,238,.92); font-family: var(--bit-font); font-size: 16px; font-weight: 900; cursor: pointer; }
.toolDec { background: rgba(255,80,80,.20); border-color: rgba(255,80,80,.25); }
.toolInc { background: rgba(40,240,122,.18); border-color: rgba(40,240,122,.25); }
.btnReset { color: rgba(232,232,238,.95); }
.btnReset:hover { background: rgba(255,80,80,.18); border-color: rgba(255,80,80,.35); }

/* === CONTAINER QUERIES === */
@container (max-width: 1050px) {
  .readoutContainer { gap: 40px; }
  .colorGroupWrap { gap: 10px; }
  .colorGroup { padding: 10px; gap: 8px; border-radius: 16px; }
  .hexCard { padding: 12px 8px; width: 140px; gap: 12px; }
  .hexDigitDisplay { font-size: 40px; }
  .hexNibbleBulb { width: 24px !important; height: 24px !important; }
  .hexNibbleLabel { font-size: 20px; }
  .hexColWeight { font-size: 26px; margin-top: 10px; }
  .hexCardBtn { width: 34px; height: 34px; font-size: 14px; }
}

@container (max-width: 800px) {
  .readoutContainer { flex-direction: column; gap: 24px; }
  .colorPreviewSide { padding-top: 0; }
  .colorGroupWrap { gap: 6px; }
  .colorGroup { padding: 6px; gap: 6px; border-radius: 12px; }
  .hexCard { padding: 8px 4px; width: 90px; gap: 8px; border-radius: 10px; }
  .hexDigitDisplay { font-size: 32px; }
  .hexNibbleBulb { width: 16px !important; height: 16px !important; }
  .hexNibbleLabel { font-size: 16px; }
  .hexColWeight { font-size: 20px; margin-top: 6px; }
  .hexCardBtn { width: 28px; height: 28px; font-size: 12px; }
  .denaryValue, .hexValue, .binaryValue { font-size: 32px; gap: 10px; }
}

@media (max-width: 1100px) { .binaryPage { --toolbox-w: 330px; } .denaryValue { font-size: 48px; }  .hexValue { font-size: 40px; } .binaryValue { font-size: 32px; } }
@media (max-width: 900px) { .binaryPage { --toolbox-w: 320px; } .bitsGrid { grid-template-columns: repeat(var(--cols), minmax(84px, 1fr)); } .hexGrid { grid-template-columns: repeat(var(--cols), minmax(130px, 1fr)); } }

.cc-sa:before {
  background-image: url(https://creativecommons.org/wp-content/themes/vocabulary-theme/vocabulary/svg/cc/icons/cc-icons.svg#cc-sa);
  float: left;
  margin-left: -2.5em;
  filter: invert(100%);
}

.cc-nc:before {
  background-image: url(https://creativecommons.org/wp-content/themes/vocabulary-theme/vocabulary/svg/cc/icons/cc-icons.svg#cc-nc);
  float: left;
  margin-left: -2.5em;
  filter: invert(100%);
}

.cc-by:before {
  background-image: url(https://creativecommons.org/wp-content/themes/vocabulary-theme/vocabulary/svg/cc/icons/cc-icons.svg#cc-by);
  float: left;
  margin-left: -2.5em;
  filter: invert(100%);
}

.cc-terms ul > li {
  padding-left: 2.5em;
  clear: both;
  list-style: none;
  margin-bottom: 2em;
  min-height: 2em;
}

.cc-terms ul {
  padding: 0;
  font-size: 1.5rem;
  font-style: normal;
  font-weight: 400;
  line-height: 150%;
  margin: 0 0 2em 2em;
}

.btnRandomRunning {
  background: rgba(40,240,122,.18) !important;
  border-color: rgba(40,240,122,.35) !important;
  color: rgba(232,232,238,.95) !important; /* Added this so the text pops like the reset button */
  animation: randomPulse 750ms ease-in-out infinite;
}

@keyframes randomPulse {
  0% { box-shadow: 0 0 0 rgba(40,240,122,0); }
  50% { box-shadow: 0 0 22px rgba(40,240,122,.38); } /* Matched the .38 opacity peak */
  100% { box-shadow: 0 0 0 rgba(40,240,122,0); }
}

.btnReset { color: rgba(232,232,238,.95); }
.btnReset:hover {
  background: rgba(255,80,80,.18);
  border-color: rgba(255,80,80,.35);
  animation: resetPulse 750ms ease-in-out infinite;
}

@keyframes resetPulse {
  0% { box-shadow: 0 0 0 rgba(255,80,80,0); }
  50% { box-shadow: 0 0 22px rgba(255,80,80,.38); }
  100% { box-shadow: 0 0 0 rgba(255,80,80,0); }
}

/* --- ACCORDION ANIMATIONS FOR ALL TOOLBOXES --- */
.panelCol .cardTitle,
.pb-toolbox .cardTitle,
.lg-toolbox .cardTitle {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.panelCol .cardTitle::after,
.pb-toolbox .cardTitle::after,
.lg-toolbox .cardTitle::after {
  content: '▼';
  font-size: 0.7em;
  opacity: 0.6;
  transition: transform 0.25s ease;
}

.panelCol .card.collapsed .cardTitle::after,
.pb-toolbox .card.collapsed .cardTitle::after,
.lg-toolbox .card.collapsed .cardTitle::after {
  transform: rotate(90deg);
}

.panelCol .cardBody,
.pb-toolbox .cardBody,
.lg-toolbox .cardBody {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 350ms cubic-bezier(0.2, 0.9, 0.2, 1);
  margin-top: 12px;
}

.panelCol .card.collapsed .cardBody,
.pb-toolbox .card.collapsed .cardBody,
.lg-toolbox .card.collapsed .cardBody {
  grid-template-rows: 0fr;
  margin-top: 0;
}

.panelCol .cardBodyInner,
.pb-toolbox .cardBodyInner,
.lg-toolbox .cardBodyInner {
  overflow: hidden;
  opacity: 1;
  transition: opacity 250ms ease 100ms, visibility 0s 0s; 
}

.panelCol .card.collapsed .cardBodyInner,
.pb-toolbox .card.collapsed .cardBodyInner,
.lg-toolbox .card.collapsed .cardBodyInner {
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease 0s, visibility 0s 200ms;
}

/* --- BASE STATE: Lock the scale so it never stretches --- */
.btnRandom, #btnRandom, 
.btnReset, #btnReset {
    transform: scale(1) !important;
    transition: transform 0.1s ease-out, border-color 0.2s ease-out, color 0.2s ease-out !important;
}

/* --- THE PULSE ANIMATIONS --- */
@keyframes neonPulseGreen {
    0%, 100% {
        background-color: rgba(40, 240, 122, 0.05);
        box-shadow: inset 0 0 10px rgba(40, 240, 122, 0.4), 
                    0 0 5px rgba(40, 240, 122, 0.2);
    }
    50% {
        background-color: rgba(40, 240, 122, 0.15);
        box-shadow: inset 0 0 22px rgba(40, 240, 122, 0.8), 
                    0 0 12px rgba(40, 240, 122, 0.5);
    }
}

@keyframes neonPulseRed {
    0%, 100% {
        background-color: rgba(255, 85, 85, 0.05);
        box-shadow: inset 0 0 10px rgba(255, 85, 85, 0.4), 
                    0 0 5px rgba(255, 85, 85, 0.2);
    }
    50% {
        background-color: rgba(255, 85, 85, 0.15);
        box-shadow: inset 0 0 22px rgba(255, 85, 85, 0.8), 
                    0 0 12px rgba(255, 85, 85, 0.5);
    }
}

/* --- HOVER STATES: Trigger the infinite pulse --- */
.btnRandom:hover, .btnRandom:focus, .btnRandom.active,
#btnRandom:hover, #btnRandom:focus, #btnRandom.active {
    border-color: #28f07a !important;
    color: #28f07a !important;
    /* 1.5s cycle, infinite loop, smooth easing */
    animation: neonPulseGreen 1.5s infinite ease-in-out !important;
}

.btnReset:hover, .btnReset:focus, .btnReset.active,
#btnReset:hover, #btnReset:focus, #btnReset.active {
    border-color: #ff5555 !important;
    color: #ff5555 !important;
    /* 1.5s cycle, infinite loop, smooth easing */
    animation: neonPulseRed 1.5s infinite ease-in-out !important;
}

/* --- CLICK STATE: Interrupt the pulse and shrink --- */
.btnRandom:active, #btnRandom:active,
.btnReset:active, #btnReset:active {
    transform: scale(0.96) !important; 
    animation: none !important; /* Immediately kill the pulse while clicked */
    background-color: transparent !important;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8) !important; 
}