/* Enhancements: hero stats, skill chips, P0 case study, terminal */

:root{
  /* --skin-color comes from the active theme file (red.css, blue.css, ...) */
  --ink: #302e4c;
  --ink-soft: #504e70;
  --card: #ffffff;
  --line: #e3e1ef;
  --chip-bg: #f7f6fd;
  --ok: #1f9d55;
  --warn: #d98a00;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
body.dark{
  --ink: #ffffff;
  --ink-soft: #e9e9e9;
  --card: #222222;
  --line: #393939;
  --chip-bg: #2a2a2a;
}
.mono{ font-family: var(--mono); }

/* ---------- Hero ---------- */
.home .intro .role-line{
  margin: 0 0 14px;
  font-weight: 600;
  color: var(--ink);
}
.role-rotator{
  color: var(--skin-color, #e40017);
  display: inline-block;
  transition: opacity .3s ease, transform .3s ease;
}
.role-rotator.out{
  opacity: 0;
  transform: translateY(6px);
}
.impact-stats{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 30px auto 0;
  max-width: 860px;
}
.impact-stats .stat{
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--skin-color, #e40017);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
}
.impact-stats .stat-value{
  font-family: 'Rubik', sans-serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.impact-stats .stat-value small{
  font-size: 16px;
  margin-left: 3px;
  color: var(--skin-color, #e40017);
}
.home .intro .impact-stats .stat-label{
  margin-top: 6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-soft);
}
.hero-actions{
  margin-top: 26px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn.btn-ghost{
  background: transparent !important;
  color: var(--ink);
  border: 2px solid var(--skin-color, #e40017);
  cursor: pointer;
  font-size: 16px;
  padding: 10px 33px;
}
.btn.btn-ghost:hover{ color: var(--skin-color, #e40017); }
.home .intro .terminal-hint{
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  opacity: .8;
}
kbd{
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--chip-bg);
}

/* ---------- About: overview list ---------- */
.about .about-content .about-text ul li{
  color: var(--ink-soft);
  line-height: 25px;
}
.about .about-content .about-text ul li strong{
  color: var(--ink);
}

/* ---------- Dark mode fixes for inline-styled blocks ---------- */
/* These elements carry inline colors in index.html, so overrides need !important */
body.dark #testimonials .shadow-dark{
  background: #222222 !important;
}
body.dark #testimonials .shadow-dark p{
  color: #e9e9e9 !important;
}
body.dark #testimonials .shadow-dark p strong{
  color: #ffffff;
}
body.dark .project .project-info p[style]{
  color: #b5b5b5 !important;
}

/* ---------- Company logos ---------- */
.company-logo{
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 6px 12px;
  margin-bottom: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.company-logo img{
  height: 18px;
  width: auto;
  display: block;
}
.company-logo.lockup{
  height: 48px;
}
.company-logo.lockup img{
  height: 34px;
}
.company-logo.emblem{
  height: 56px;
  padding: 4px 8px;
}
.company-logo.emblem img{
  height: 46px;
}

/* ---------- Skill chips ---------- */
.about .about-content .stack{
  flex: 0 0 100%;
  max-width: 100%;
  margin-top: 40px;
}
.stack-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-right: 50px; /* clear the fixed theme switcher */
}
.stack-head h3{
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}
.stack-filter{
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-btn{
  font: 600 13px 'Montserrat', sans-serif;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .2s ease;
}
.filter-btn:hover{ border-color: var(--skin-color, #e40017); color: var(--ink); }
.filter-btn.active{
  background: var(--skin-color, #e40017);
  border-color: var(--skin-color, #e40017);
  color: #ffffff;
}
.stack-where{
  margin: 14px 0 18px;
  min-height: 24px;
  font-size: 14px;
  color: var(--ink-soft);
}
.stack-where strong{ color: var(--skin-color, #e40017); }
.stack-groups{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.stack-group{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.stack-group h4{
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--skin-color, #e40017);
  margin-bottom: 10px;
}
.stack-group ul{
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip{
  font: 500 13px 'Montserrat', sans-serif;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  transition: opacity .25s ease, border-color .2s ease, transform .2s ease;
}
.chip:hover,
.chip:focus-visible,
.chip.selected{
  border-color: var(--skin-color, #e40017);
  transform: translateY(-1px);
}
.chip.dim{ opacity: .28; }

/* ---------- P0 case study ---------- */
.incident-wrap{ flex: 0 0 100%; max-width: 100%; }
.incident{
  background: var(--card);
  border-radius: 12px;
  padding: 28px;
}
.incident-head{
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.sev{
  flex: none;
  font: 700 14px var(--mono);
  color: #ffffff;
  background: #d7263d;
  border-radius: 6px;
  padding: 6px 10px;
}
.incident-head h3{
  font-size: 22px;
  color: var(--ink);
  line-height: 1.3;
}
.incident-meta{
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-soft);
}
.incident-status{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink);
  background: var(--chip-bg);
  border: 1px solid var(--line);
}
.incident-status .pulse{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d7263d;
  box-shadow: 0 0 0 0 rgba(215,38,61,.6);
  animation: pulse 1.6s infinite;
}
.incident-status[data-state="restored"] .pulse{ background: var(--warn); animation: none; }
.incident-status[data-state="resolved"] .pulse{ background: var(--ok); animation: none; }
@keyframes pulse{
  70%{ box-shadow: 0 0 0 10px rgba(215,38,61,0); }
  100%{ box-shadow: 0 0 0 0 rgba(215,38,61,0); }
}
.incident-steps{
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 20px 0;
  position: relative;
}
.incident-steps::before{
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 9px;
  height: 2px;
  background: var(--line);
}
.step{
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  position: relative;
  font-family: 'Montserrat', sans-serif;
}
.step::before{
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--line);
  transition: all .25s ease;
  margin-bottom: 4px;
}
.step.done::before{ border-color: var(--skin-color, #e40017); }
.step.active::before{
  background: var(--skin-color, #e40017);
  border-color: var(--skin-color, #e40017);
  transform: scale(1.2);
}
.step-time{
  font: 700 12px var(--mono);
  color: var(--skin-color, #e40017);
}
.step-name{
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.step.active .step-name{ color: var(--ink); }
.incident-panels{
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  min-height: 150px;
  background: var(--chip-bg);
}
.panel h4{
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 8px;
}
.panel p{
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 15px;
}
.panel.active{ animation: fadeUp .35s ease; }
@keyframes fadeUp{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: none; }
}
.mem-chart{ margin-top: 14px; max-width: 460px; }
.mem-chart svg{ width: 100%; height: auto; display: block; }
.mem-chart .limit{ stroke: #d7263d; stroke-width: 1.5; stroke-dasharray: 5 4; }
.mem-chart .limit-label,
.mem-chart .oom{ font: 600 11px var(--mono); fill: #d7263d; }
.mem-chart .mem-line{
  fill: none;
  stroke: var(--skin-color, #e40017);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
}
.panel.active .mem-chart .mem-line{ animation: draw 2.4s ease forwards; }
@keyframes draw{ to{ stroke-dashoffset: 0; } }
.mem-chart figcaption{
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.incident-controls{
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
.ctrl{
  font: 600 14px 'Montserrat', sans-serif;
  min-width: 42px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s ease;
}
.ctrl:hover{ border-color: var(--skin-color, #e40017); }
.ctrl-play{
  background: var(--skin-color, #e40017);
  border-color: var(--skin-color, #e40017);
  color: #ffffff;
}
.takeaways{ margin-top: 30px; }
.takeaway{
  flex: 0 0 33.33%;
  max-width: 33.33%;
  margin-bottom: 20px;
}
.takeaway-inner{
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  height: 100%;
  border-left: 4px solid var(--skin-color, #e40017);
}
.takeaway h4{ color: var(--ink); margin-bottom: 8px; font-size: 17px; }
.takeaway p{ color: var(--ink-soft); font-size: 14px; line-height: 1.6; }

/* ---------- Terminal ---------- */
.terminal-overlay{
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10,10,20,.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.terminal-overlay[hidden]{ display: none; }
.terminal{
  width: min(820px, 100%);
  height: min(560px, 85vh);
  background: #0f1117;
  border: 1px solid #2a2f3a;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font: 14px/1.6 var(--mono);
  color: #d6deeb;
  animation: fadeUp .25s ease;
}
.terminal-bar{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #171a22;
  border-bottom: 1px solid #2a2f3a;
}
.terminal-bar .dot{ width: 12px; height: 12px; border-radius: 50%; border: 0; padding: 0; }
.terminal-bar .dot.red{ background: #ff5f57; cursor: pointer; }
.terminal-bar .dot.yellow{ background: #febc2e; }
.terminal-bar .dot.green{ background: #28c840; }
.terminal-bar .title{
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #8b93a7;
  margin-right: 44px;
}
.terminal-body{
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}
.terminal-body .line{ white-space: pre-wrap; word-break: break-word; }
.terminal-body .muted{ color: #7f8aa3; }
.terminal-body .accent{ color: var(--skin-color, #e40017); }
.terminal-body .ok{ color: #7fdb8a; }
.terminal-body .err{ color: #ff7b7b; }
.terminal-body .cmd{ color: #ffd479; }
.terminal-body a{ color: #82aaff; text-decoration: underline; }
.terminal-input-row{
  display: flex;
  align-items: center;
  gap: 8px;
}
.terminal-input-row .prompt{ color: #7fdb8a; white-space: nowrap; }
.terminal-input{
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: #ffffff;
  font: inherit;
  caret-color: var(--skin-color, #e40017);
}

/* ---------- Responsive ---------- */
@media (hover: none){
  .home .intro .terminal-hint{ display: none; }
}
@media (max-width: 900px){
  .impact-stats{ grid-template-columns: repeat(2, 1fr); }
  .takeaway{ flex: 0 0 100%; max-width: 100%; }
}
@media (max-width: 600px){
  .incident{ padding: 18px; }
  .incident-head h3{ font-size: 18px; }
  .incident-steps{
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(84px, 1fr);
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .incident-steps::before{ left: 42px; right: 42px; }
  .impact-stats .stat-value{ font-size: 28px; }
  .stack-groups{ grid-template-columns: 1fr; }
  .terminal{ font-size: 13px; height: 88vh; }
  .terminal-input-row .prompt .host{ display: none; }
}
@media (prefers-reduced-motion: reduce){
  .role-rotator, .chip, .step::before{ transition: none; }
  .panel.active, .terminal{ animation: none; }
  .incident-status .pulse{ animation: none; }
  .mem-chart .mem-line{ stroke-dashoffset: 0; animation: none !important; }
}
