/* Size chart — visual defaults. JS only overrides --es-sc-accent / --es-sc-accent-foreground. */
.es-sc-popup,
.es-sc-popup--inline,
.es-sc-popup__content {
  --es-sc-max-width: 720px;
  --es-sc-overlay: rgba(0, 0, 0, 0.2);
  --es-sc-background: #ffffff;
  --es-sc-border: #eaeaea;
  --es-sc-radius: 4px;
  --es-sc-foreground: #000000;
  --es-sc-accent: #000000;
  --es-sc-accent-foreground: #ffffff;
  --es-sc-muted-background: #fafafa;
  --es-sc-badge-active-background: #eaeaea;
  --es-sc-badge-background: #ffffff;
  --es-sc-table-background: #ffffff;
  --es-sc-table-header-background: #fafafa;
  --es-sc-table-border: #eaeaea;
  --es-sc-table-radius: 4px;
  --es-sc-note-background: #eaeaea;
  --es-sc-note-border: #eaeaea;
  --es-sc-note-radius: 4px;
  --es-sc-font-family: Instrument Sans, system-ui, sans-serif;
  --es-sc-header-height: 48px;
  --es-sc-body-padding: 16px;
  --es-sc-viewport-gutter: 10px;
  --es-sc-table-cell-min-width: 100px;
  --es-sc-table-cell-max-width: 200px;
}

/* Typography isolation — storefront themes (e.g. Shopify Dawn) set font-family
   and letter-spacing on element selectors like `h2` and `button`, which beat
   inherited values. The popup always uses the Entersize font. */
.es-sc-popup,
.es-sc-popup *,
.es-sc-popup--inline,
.es-sc-popup--inline * {
  font-family: var(--es-sc-font-family);
  letter-spacing: 0;
}

.es-sc-popup {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: var(--es-sc-max-width);
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--es-sc-border);
  border-radius: var(--es-sc-radius);
  background: var(--es-sc-background);
  color: var(--es-sc-foreground);
  container-type: inline-size;
  container-name: es-sc-popup;
}

.es-sc-popup__header {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: var(--es-sc-header-height);
  padding: 0 var(--es-sc-body-padding);
  box-sizing: border-box;
}

.es-sc-popup__title {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: normal;
  color: var(--es-sc-foreground);
}

.es-sc-popup__close {
  position: absolute;
  top: 12px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--es-sc-foreground);
  cursor: pointer;
  line-height: 1;
}

.es-sc-popup__close:hover {
  opacity: 0.7;
}

.es-sc-popup__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--es-sc-body-padding);
  box-sizing: border-box;
}

.es-sc-popup__content {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  min-height: 100%;
  gap: 12px;
}

.es-sc-popup__product-name {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: normal;
  color: var(--es-sc-foreground);
}

.es-sc-popup__intro {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.es-sc-popup__note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: 100%;
  min-height: 32px;
  padding: 8px 12px;
  box-sizing: border-box;
  border: 1px solid var(--es-sc-note-border);
  border-radius: var(--es-sc-note-radius);
  background: var(--es-sc-note-background);
  color: var(--es-sc-foreground);
}

.es-sc-popup__note svg {
  flex-shrink: 0;
}

.es-sc-popup__note-text {
  margin: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  line-height: normal;
}

.es-sc-popup__logo {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  color: #aeaeae;
  height: 16px;
  margin-top: auto;
}

.es-sc-popup__logo a {
  display: inline-flex;
  color: inherit;
  text-decoration: none;
}

.es-sc-popup__logo svg {
  height: 10px;
  width: auto;
}

.es-sc-popup__debug {
  width: 100%;
  padding: 8px 12px;
  box-sizing: border-box;
  border: 1px solid #ffdc20;
  border-radius: var(--es-sc-radius);
  background: #fffbea;
  font-size: 11px;
  line-height: 1.4;
  color: #000;
}

.es-sc-popup__debug-title {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
}

.es-sc-popup__debug-line {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}

.es-sc-popup__tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.es-sc-popup__tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 12px;
  border: 1px solid var(--es-sc-border);
  border-radius: 24px;
  background: var(--es-sc-badge-background);
  color: var(--es-sc-foreground);
  font-family: inherit;
  font-size: 12px;
  line-height: normal;
  cursor: pointer;
  white-space: nowrap;
}

.es-sc-popup__tab.is-active {
  background: var(--es-sc-badge-active-background);
}

.es-sc-popup__tab:focus-visible {
  outline: 2px solid #000099;
  outline-offset: 2px;
}

.es-sc-popup__table-host {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--es-sc-table-border);
  border-radius: var(--es-sc-table-radius);
  overflow: hidden;
  background: var(--es-sc-table-background);
}

.es-sc-popup__table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.es-sc-popup__table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.es-sc-popup__table th,
.es-sc-popup__table td {
  width: auto;
  min-width: var(--es-sc-table-cell-min-width);
  max-width: var(--es-sc-table-cell-max-width);
  height: 32px;
  padding: 8px 12px;
  border: 0;
  border-right: 1px solid var(--es-sc-table-border);
  border-bottom: 1px solid var(--es-sc-table-border);
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  line-height: normal;
  color: var(--es-sc-foreground);
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-sc-popup__table thead th {
  border-top: none;
  border-bottom: 1px solid var(--es-sc-table-border);
}

.es-sc-popup__table tbody tr:first-child th,
.es-sc-popup__table tbody tr:first-child td {
  border-top: none;
}

.es-sc-popup__table tbody tr:last-child th,
.es-sc-popup__table tbody tr:last-child td {
  border-bottom: none;
}

.es-sc-popup__table th:first-child,
.es-sc-popup__table td:first-child {
  border-left: none;
}

.es-sc-popup__table th:last-child,
.es-sc-popup__table td:last-child {
  border-right: none;
}

.es-sc-popup__table th:first-child {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: none;
  /* Safari: box-shadow survives sticky scroll better than border-right */
  box-shadow: inset -1px 0 0 var(--es-sc-table-border);
}

.es-sc-popup__table thead th:first-child {
  z-index: 2;
}

.es-sc-popup__table thead th,
.es-sc-popup__table tbody th {
  background: var(--es-sc-table-header-background);
}

.es-sc-popup__table tbody td {
  background: var(--es-sc-table-background);
}

.es-sc-popup__unit-toggle {
  display: inline-flex;
  align-items: center;
  height: 32px;
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--es-sc-border);
  border-radius: 9999px;
  box-sizing: border-box;
  user-select: none;
}

.es-sc-popup__content--illustrated .es-sc-popup__unit-toggle--footer {
  display: none;
}

.es-sc-popup__unit-segments {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  background: var(--es-sc-background);
}

.es-sc-popup__unit-segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 24px;
  padding: 0 12px;
  border: 0;
  border-radius: 9999px;
  background: var(--es-sc-background);
  font-family: inherit;
  font-size: 12px;
  line-height: normal;
  color: var(--es-sc-foreground);
  cursor: pointer;
}

.es-sc-popup__unit-segment:focus-visible {
  outline: 2px solid #000099;
  outline-offset: 2px;
}

.es-sc-popup__unit-segment.is-active {
  background: var(--es-sc-badge-active-background);
}

.es-sc-popup__message {
  margin: 0;
  font-size: 14px;
  color: #555;
}

.es-sc-popup__message.is-error {
  color: #ff232d;
}

.es-sc-popup--inline {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: var(--es-sc-max-width);
  max-height: none;
  margin-inline: auto;
}

/* Illustrated template layout (t-shirt) */
.es-sc-popup__table-host--illustrated {
  border: 0;
  background: transparent;
  overflow: visible;
}

.es-sc-popup__illustrated-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}

.es-sc-popup__illustration-host {
  flex: none;
  width: 100%;
  min-width: 0;
}

.es-sc-popup__illustration-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--es-sc-border);
  border-radius: var(--es-sc-radius);
  background: var(--es-sc-background);
  overflow: hidden;
}

.es-sc-popup__illustration-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--es-sc-foreground);
  pointer-events: none;
}

.es-sc-popup__illustration-svg line {
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.es-sc-popup__illustration-artwork path {
  fill: none;
  stroke: #eaeaea;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-miterlimit: 10;
  vector-effect: non-scaling-stroke;
}

.es-sc-popup__illustration-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.es-sc-popup__illustration-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border-radius: var(--es-sc-radius);
  background: var(--es-sc-badge-active-background);
  color: var(--es-sc-foreground);
  font-size: 10px;
  line-height: normal;
  white-space: nowrap;
}

.es-sc-popup__illustrated-controls {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.es-sc-popup__size-picker-label {
  margin: 0;
  font-size: 14px;
  line-height: normal;
  color: var(--es-sc-foreground);
}

.es-sc-popup__size-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.es-sc-popup__size-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 32px;
  padding: 8px 12px;
  border: 1px solid var(--es-sc-border);
  border-radius: var(--es-sc-radius);
  background: var(--es-sc-badge-background);
  color: var(--es-sc-foreground);
  font-family: inherit;
  font-size: 12px;
  line-height: normal;
  cursor: pointer;
  box-sizing: border-box;
}

.es-sc-popup__size-chip.is-active {
  background: var(--es-sc-accent);
  border-color: var(--es-sc-accent);
  color: var(--es-sc-accent-foreground);
}

.es-sc-popup__size-chip:focus-visible {
  outline: 2px solid #000099;
  outline-offset: 2px;
}

/* Matches Tailwind sm (640px), but against the popup width — not the page viewport. */
@container es-sc-popup (min-width: 40rem) {
  .es-sc-popup__illustrated-layout {
    flex-direction: row;
    gap: 16px;
  }

  .es-sc-popup__illustration-host,
  .es-sc-popup__illustrated-controls {
    flex: 1 1 0;
    width: auto;
  }
}
