/*
 * Tool pages only (tools/<slug>/*.html).
 * Not loaded on the gallery home — keeps global styles.css smaller.
 */

.tool{
  max-width: 52rem;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.tool > .tool-breadcrumb{
  order: -2;
  width: 100%;
  margin: 0 0 10px;
}

.tool-breadcrumb__list{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--muted);
}

.tool-breadcrumb__item{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tool-breadcrumb__item:not(:last-child)::after{
  content: "/";
  color: rgba(240, 180, 41, 0.9);
  font-weight: 800;
  pointer-events: none;
}

.tool-breadcrumb__link{
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(232, 93, 68, 0.45);
}

.tool-breadcrumb__link:hover{
  color: var(--accent-hover);
}

.tool-breadcrumb__item--current{
  color: var(--text);
  font-weight: 750;
}

/* Topbar share button */
.topbar__iconbtn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 2px solid rgba(45, 42, 38, 0.14);
  background: rgba(255, 254, 248, 0.8);
  color: var(--text);
  box-shadow: 2px 2px 0 rgba(45, 42, 38, 0.08);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar__iconbtn:hover{
  transform: translate(-1px, -1px);
  border-color: rgba(232, 93, 68, 0.35);
  box-shadow: 3px 3px 0 rgba(45, 42, 38, 0.1);
}

.topbar__iconbtn:active{
  transform: translate(0, 0);
  box-shadow: 2px 2px 0 rgba(45, 42, 38, 0.08);
}

.topbar__iconbtn:focus-visible{
  outline: none;
  box-shadow: var(--ring-offset), var(--ring);
}

.topbar__iconbtn--ok{
  border-color: rgba(34, 197, 94, 0.5);
}

.tool > h1{
  font-family: var(--font-display);
  order: 0;
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3.4vw, 2.05rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.12;
  color: var(--ink);
  text-shadow: 2px 2px 0 rgba(240, 180, 41, 0.28);
}

.tool > .lead{
  order: 1;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
  max-width: 40rem;
}

/* Errors / live status sit above the main panel but stay secondary to the title line. */
.tool > [role="alert"],
.tool > [aria-live="polite"]{
  order: 2;
  width: 100%;
}

.tool > .panel{
  order: 3;
}

/* Outbound promo — after the main panel so the interactive surface stays the hero. */
.tool > .tool-ext-link{
  order: 4;
  margin: 18px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  max-width: 42rem;
  color: var(--muted);
  opacity: 0.92;
}

.tool-ext-link a{
  font-weight: 800;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(232, 93, 68, 0.45);
}

.tool-ext-link a:hover{
  color: var(--accent-hover);
}

.tool > .tool-ext-link + .tool-ext-link{
  margin-top: 6px;
}

.panel{
  border: 2px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px 24px 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.panel::before{
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent-sunny), var(--accent), var(--accent-2), var(--accent-3));
  opacity: 1;
  pointer-events: none;
}

/* Short how-to inside tool panels — visually subordinate to primary controls. */
.tool-directions{
  margin: 0 0 12px;
  padding: 10px 14px 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border: none;
  border-left: 4px solid var(--accent-2);
  background: rgba(46, 184, 158, 0.08);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--muted);
}

.tool-directions strong{
  color: var(--text);
  font-weight: 750;
}

.sr-only{
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Related tools (injected by assets/tool-cross.js into #toolCrossRoot) */
.tool-cross-mount:empty{
  display: none;
}

.tool-cross-mount{
  margin-top: 28px;
  max-width: 52rem;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.tool-cross .tool-cross__title{
  font-family: var(--font-display);
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text);
  opacity: 0.9;
}

.tool-cross__list{
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.tool-cross__link{
  display: block;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: rgba(255, 254, 248, 0.85);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tool-cross__link:hover{
  border-color: var(--accent-3);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translate(-2px, -2px);
}

.tool-cross__link:focus-visible{
  outline: none;
  box-shadow: var(--ring-offset), var(--ring);
}

.tool-cross__name{
  font-family: var(--font-display);
  display: block;
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.tool-cross__desc{
  display: block;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
}

.tool-cross__more{
  margin: 16px 0 0;
  font-size: 0.88rem;
}

.tool-cross__more a{
  font-weight: 800;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(232, 93, 68, 0.45);
}

.tool-cross__more a:hover{
  color: var(--accent-hover);
}

@media (prefers-reduced-motion: reduce){
  .tool-cross__link:hover{
    transform: none;
  }
}

/*
 * Shared UX baseline: keyboard focus ring across tool controls.
 * Tool pages frequently use custom button/input classes; this keeps focus styling consistent.
 */
.tool button:focus-visible,
.tool a:focus-visible,
.tool input:focus-visible,
.tool select:focus-visible,
.tool textarea:focus-visible{
  outline: none;
  box-shadow: var(--ring-offset), var(--ring);
}

/* =========================
 * Shared tool UI components
 * ========================= */

/* Chips / segmented controls (use with role="group" and aria-pressed). */
.ui-chip-group{
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ui-chip{
  appearance: none;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-strong);
  background: rgba(255, 254, 248, 0.9);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(45, 42, 38, 0.08);
  transition:
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.ui-chip:hover{
  transform: translate(-1px, -1px);
  border-color: rgba(107, 92, 255, 0.55);
  background: rgba(107, 92, 255, 0.08);
  box-shadow: 4px 4px 0 rgba(45, 42, 38, 0.1);
}

.ui-chip:active{
  transform: translate(0, 0);
  box-shadow: 2px 2px 0 rgba(45, 42, 38, 0.08);
}

.ui-chip[aria-pressed="true"]{
  border-color: rgba(107, 92, 255, 0.65);
  background: rgba(107, 92, 255, 0.16);
}

/* Big choice buttons (emoji choices, doors, etc.). */
.ui-choice-row{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.ui-choice{
  appearance: none;
  border: 2px solid var(--border-strong);
  background: rgba(255, 254, 248, 0.95);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: 0.02em;
  font-size: 1.35rem;
  transition:
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.ui-choice:hover{
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(240, 180, 41, 0.75);
}

.ui-choice:active{
  transform: translate(0, 0);
  box-shadow: var(--shadow-md);
}

@media (max-width: 420px){
  .ui-choice{
    min-height: 56px;
    font-size: 1.2rem;
  }
}

/* Live state / progress (scores, timers, status lines, “last result”, etc.) */
.ui-hud{
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
}

.ui-stat{
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-strong);
  background: rgba(255, 254, 248, 0.88);
  box-shadow: 2px 2px 0 rgba(45, 42, 38, 0.08);
  font-variant-numeric: tabular-nums;
}

.ui-stat__label{
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-size: 0.82rem;
}

.ui-stat__value{
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  font-size: 0.95rem;
}

/* Generic live-status line. Intended for small, changing text (not big preview regions). */
.ui-live{
  margin: 0;
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(45, 42, 38, 0.08);
  background: rgba(255, 254, 248, 0.7);
  box-shadow: 2px 2px 0 rgba(45, 42, 38, 0.06);
  font-weight: 650;
  color: var(--muted);
  text-align: center;
}

.ui-live:where(span){
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}

.ui-live strong{
  color: var(--text);
  font-weight: 750;
}

/* Recent history (e.g., last rolls, last results). */
.ui-history{
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.ui-history > li{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(45, 42, 38, 0.06);
  border: 1px solid rgba(45, 42, 38, 0.06);
  box-shadow: 1px 1px 0 rgba(45, 42, 38, 0.04);
  font-variant-numeric: tabular-nums;
}

.ui-history:empty::before{
  content: "No history yet.";
  padding: 0.25rem 0.25rem;
  color: var(--muted);
}


