/* Module: sections 07-10 of automation 11 (Shopify store ops).
   #features (tiles), #dashboard (store ops window), #stack and #industries.
   Every rule is scoped under its section id; every class invented here starts with so-.
   Frames and shared pieces come from features.css, dashboard.css and site.css. */

/* ---------- 07 / Features: every title reserves two lines, so each body starts on the same y ---------- */

#features .features-tile .cell-t {
  min-height: 2.3em;
  max-width: 14ch;
  text-wrap: pretty;
}

#features .features-tile .cell-p {
  text-wrap: pretty;
}

@media (min-width: 1280px) {
  #features .features-tile .cell-t {
    max-width: 20ch;
  }
}

/* ---------- 08 / Dashboard: window and palette ---------- */

/* Amber is the "watch" colour in the dark UI; gold is reserved for what the automation did. */
#dashboard {
  --so-amber: hsl(30 88% 56%);
}

#dashboard .so-dash-body {
  display: block;
}

@media (min-width: 1280px) {
  #dashboard .so-dash-body {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
  }
}

#dashboard .so-dash-main {
  min-width: 0;
}

/* Labels and sub-lines wrap rather than truncate: the cards are narrow at 1280 and 390 */
#dashboard .so-dash .dashboard-stat-l,
#dashboard .so-dash .dashboard-stat-s,
#dashboard .so-dash .dashboard-meta {
  white-space: normal;
  text-overflow: clip;
}

#dashboard .so-dash .dashboard-stat-l {
  text-wrap: balance;
}

#dashboard .so-dash .dashboard-bar-title {
  white-space: normal;
  line-height: 1.4;
}

@media (max-width: 639px) {
  #dashboard .so-dash .dashboard-bar {
    height: auto;
    min-height: 40px;
    padding-block: 10px;
  }
}

/* The business name wraps in the rail instead of running past its edge */
#dashboard .so-dash .dashboard-rail-name b {
  white-space: normal;
  line-height: 1.2;
}

#dashboard .so-dash .dashboard-foot-sync {
  display: inline;
}

/* ---------- Two columns under the cards (1.4fr / 1fr from 1024) ---------- */

#dashboard .so-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

#dashboard .so-col-left,
#dashboard .so-block {
  min-width: 0;
}

#dashboard .so-block .dashboard-toolbar {
  padding-bottom: 16px;
}

#dashboard .so-reviews {
  border-top: 1px solid var(--line);
}

#dashboard .so-weeks {
  border-top: 1px solid var(--line);
}

@media (min-width: 1024px) {
  #dashboard .so-columns {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }

  #dashboard .so-reviews {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  #dashboard .so-weeks {
    border-top: 1px solid var(--line);
  }
}

/* ---------- Stock health: a plain table on hairlines ---------- */

#dashboard .so-table-wrap {
  padding: 0 20px 12px;
  overflow-x: auto;
}

#dashboard .so-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.3;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

#dashboard .so-table th {
  padding: 0 12px 10px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

#dashboard .so-table td {
  height: 40px;
  padding: 0 12px 0 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

#dashboard .so-table tbody tr:last-child td {
  border-bottom: 0;
}

#dashboard .so-table .so-num {
  text-align: right;
  white-space: nowrap;
}

#dashboard .so-table td.so-num:not(.so-days) {
  color: var(--bone-80);
}

#dashboard .so-table .so-days {
  color: var(--bone);
}

/* The status column starts a clear step after "Days left" and never touches it */
#dashboard .so-table td:last-child,
#dashboard .so-table th:last-child {
  padding-left: 20px;
  padding-right: 0;
}

#dashboard .so-prod {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

#dashboard .so-glyph {
  display: block;
  flex: none;
  width: 12px;
  height: 16px;
}

#dashboard .so-glyph svg {
  display: block;
  width: 100%;
  height: 100%;
}

#dashboard .so-prod-n {
  min-width: 0;
  font-size: 15px;
  color: var(--bone);
  text-wrap: balance;
}

#dashboard .so-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 40px;
  white-space: nowrap;
}

#dashboard .so-status-t {
  font-size: 14px;
  line-height: 1.3;
  color: var(--bone-70);
}

#dashboard .so-dot {
  display: block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

#dashboard .so-dot--red {
  background: var(--danger);
}

#dashboard .so-dot--amber {
  background: var(--so-amber);
}

#dashboard .so-dot--green {
  background: var(--ok);
}

/* ---------- Carts recovered by week: bars on one scale, labels above each bar ---------- */

#dashboard .so-weeks-body {
  padding: 0 20px 20px;
}

#dashboard .so-weeks-plot {
  position: relative;
  display: grid;
  height: 190px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

#dashboard .so-wk {
  position: relative;
  min-width: 0;
  height: 100%;
}

#dashboard .so-wk-bar {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 0;
  height: var(--h, 0px);
  background: hsl(42 30% 94% / 0.22);
  transform-origin: bottom center;
}

#dashboard .so-wk-rec {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--accent);
}

#dashboard .so-wk-val {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--h, 0px) + 8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#dashboard .so-wk-rv {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

#dashboard .so-wk-av {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ash);
}

#dashboard .so-wk--now .so-wk-rv,
#dashboard .so-wk--now .so-wk-av {
  color: var(--bone);
}

#dashboard .so-weeks-x {
  display: grid;
  margin: 0;
  padding: 10px 0 0;
  list-style: none;
}

#dashboard .so-wk-x {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  color: var(--ash);
}

#dashboard .so-wk-x--now {
  color: var(--bone);
}

/* Bars grow once when the window scrolls into view. Heights are already in the markup as the
   finished value, so ?static=1, reduced motion and no-JS all show the finished state. */
#dashboard .so-dash--play .so-wk-bar {
  animation: so-sec-grow 0.9s var(--ease-out) both;
  animation-delay: var(--i, 0s);
}

@keyframes so-sec-grow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

#dashboard .so-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#dashboard .so-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#dashboard .so-key {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
}

#dashboard .so-key--gold {
  background: var(--accent);
}

#dashboard .so-key--bone {
  background: hsl(42 30% 94% / 0.22);
}

#dashboard .so-caption {
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

/* ---------- Review replies ---------- */

#dashboard .so-reviews-list {
  margin: 0;
  padding: 0 20px 8px;
  list-style: none;
}

#dashboard .so-rev {
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
}

#dashboard .so-rev:first-child {
  border-top: 0;
}

#dashboard .so-rev-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

#dashboard .so-rev-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

#dashboard .so-stars {
  display: inline-flex;
  gap: 2px;
  flex: none;
}

#dashboard .so-star {
  display: block;
  width: 12px;
  height: 12px;
  fill: var(--line);
}

#dashboard .so-star--on {
  fill: var(--accent);
}

#dashboard .so-rev-name {
  font-size: 15px;
  color: var(--bone);
}

#dashboard .so-rev-prod {
  font-size: 14px;
  color: var(--ash);
}

#dashboard .so-rev-time {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

#dashboard .so-rev-text {
  margin: 8px 0 10px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--bone-70);
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#dashboard .so-chip {
  display: inline-block;
  padding: 3px 8px 4px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}

#dashboard .so-chip--ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

#dashboard .so-chip--amber {
  color: var(--so-amber);
  border-color: color-mix(in srgb, var(--so-amber) 40%, transparent);
}

/* ---------- Phones: sales-a-day column dropped from the stock table ---------- */

@media (max-width: 639px) {
  #dashboard .so-col-perday {
    display: none;
  }

  #dashboard .so-table-wrap {
    padding: 0 16px 10px;
  }

  #dashboard .so-weeks-body,
  #dashboard .so-reviews-list {
    padding-inline: 16px;
  }

  /* Four columns fit 358px: the table is tighter, the status text may wrap, and nothing is clipped */
  #dashboard .so-table {
    font-size: 14px;
  }

  #dashboard .so-table th {
    padding-right: 8px;
  }

  #dashboard .so-table td {
    padding-right: 8px;
  }

  #dashboard .so-table td:last-child,
  #dashboard .so-table th:last-child {
    padding-left: 12px;
  }

  #dashboard .so-prod {
    gap: 8px;
  }

  #dashboard .so-prod-n {
    font-size: 14px;
  }

  #dashboard .so-status {
    height: auto;
    min-height: 40px;
    align-items: flex-start;
    padding-top: 13px;
  }

  #dashboard .so-status-t {
    font-size: 13px;
    white-space: normal;
  }

  #dashboard .so-table-wrap {
    overflow-x: visible;
  }

  /* Fixed widths: product gets the room, the status column keeps its text on one or two lines */
  #dashboard .so-table {
    table-layout: fixed;
  }

  #dashboard .so-table th,
  #dashboard .so-table th.so-num {
    white-space: normal;
    letter-spacing: 0.04em;
    line-height: 1.4;
  }

  #dashboard .so-table th:nth-child(1),
  #dashboard .so-table td:nth-child(1) {
    width: 36%;
  }

  #dashboard .so-table th:nth-child(2),
  #dashboard .so-table td:nth-child(2) {
    width: 20%;
  }

  #dashboard .so-table th:nth-child(4),
  #dashboard .so-table td:nth-child(4) {
    width: 13%;
  }
}

/* ---------- 09 / Stack: seven tools on hairlines ----------
   Each cell draws its own hairlines, so any column count works. 7 across from 1280,
   4 + 3 from 1024, 2 wide from 640 and one wide below that. */

#stack .so-stack {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#stack .so-stack > * {
  min-width: 0;
  padding: 28px 22px;
  border-left: 0;
  border-top: 0;
}

#stack .so-stack .features-glyph {
  margin-bottom: 24px;
}

#stack .features-caption {
  margin-top: 24px;
}

#stack .so-tool-text {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#stack .so-tool-r {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ash);
  text-wrap: pretty;
}

#stack .so-stack > *:hover .so-tool-r {
  color: var(--bone-70);
}

@media (min-width: 1280px) {
  #stack .so-stack {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  #stack .so-stack > *:nth-child(n + 2) {
    border-left: 1px solid var(--line);
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  #stack .so-stack > *:nth-child(4n + 2),
  #stack .so-stack > *:nth-child(4n + 3),
  #stack .so-stack > *:nth-child(4n + 4) {
    border-left: 1px solid var(--line);
  }

  #stack .so-stack > *:nth-child(n + 5) {
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #stack .so-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #stack .so-stack > *:nth-child(2n) {
    border-left: 1px solid var(--line);
  }

  #stack .so-stack > *:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 639px) {
  #stack .so-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  #stack .so-stack > *:nth-child(n + 2) {
    border-top: 1px solid var(--line);
  }

  /* One tool per row: glyph on the left, name with its line of copy beside it */
  #stack .so-stack > * {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 0;
  }

  #stack .so-stack .features-glyph {
    flex: none;
    margin: 2px 0 0;
  }

  #stack .so-stack .so-tool-r {
    font-size: 1rem;
  }
}

/* ---------- 10 / Built for: name and one line per row ---------- */

#industries .so-ind-row {
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  padding: 24px 0;
}

#industries .so-ind-text {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#industries .so-ind-row .features-hex {
  margin-top: 8px;
}

#industries .so-ind-line {
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ash);
  text-wrap: pretty;
}

@media (max-width: 767px) {
  #industries .so-ind-row {
    min-height: 0;
    padding: 20px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #dashboard .so-dash--play .so-wk-bar {
    animation: none;
  }
}
