/* Mighty Andy free tools: shared layout for every page under /tools/.
   Loaded after /assets/insights/insights.css, whose tokens, nav, footer,
   crumbs, label, title and sign-off styles it reuses.

   Layout: the title and the tool share one centre line at every width.
   Wide screens put short margin notes in the space either side of the
   tool; narrower ones stack them underneath, at the same width as the
   title so every edge lines up. */

.tool-page {
  max-width: calc(1200px + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* The centre column, shared by the header, the tool, the write-up and the footer. */
.tool-col { max-width: var(--measure); margin-left: auto; margin-right: auto; }

.tool-head { padding-top: 52px; }
.tool-head .crumbs { margin-bottom: 40px; }
.tool-head .article-title { margin-bottom: 14px; }
.tool-head .standfirst { font-size: clamp(17px, 2vw, 20px); }

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, var(--measure));
  justify-content: center;
  gap: 28px;
  margin-top: 36px;
}

.tool {
  background: #fff;
  border: 1px solid var(--paper-dark);
  border-top: 4px solid var(--red);
  padding: 28px 28px 24px;
  box-shadow: 0 1px 0 var(--paper-dark), 0 18px 40px -28px rgba(42, 37, 32, 0.35);
}

/* Margin notes. */
.notes { display: grid; gap: 16px; align-content: start; }
.note {
  font-size: 14px;
  line-height: 1.55;
  color: var(--charcoal-mid);
  border-left: 2px solid var(--red);
  padding: 2px 0 2px 14px;
}
.note-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 4px;
}
.note a { color: var(--charcoal); text-decoration-color: var(--red); text-underline-offset: 3px; }

/* Narrow and medium: tool first, notes underneath in two columns. */
.tool { order: 1; }
.notes-left { order: 2; }
.notes-right { order: 3; }
@media (min-width: 560px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, calc(var(--measure) / 2 - 14px))); }
  .tool-grid .tool { grid-column: 1 / -1; }
}
@media (max-width: 520px) { .tool { padding: 22px 18px; } }

/* Wide: notes in the margins, the tool on the title's centre line. */
@media (min-width: 1100px) {
  .tool-page { --tool-w: 640px; }
  .tool-col { max-width: var(--tool-w); }
  .tool-head.tool-col { padding-left: 0; padding-right: 0; }
  .tool-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--tool-w)) minmax(0, 1fr);
    align-items: start;
    gap: 40px;
  }
  .tool-grid .tool { grid-column: 2; grid-row: 1; }
  .notes-left { grid-column: 1; grid-row: 1; justify-self: end; max-width: 230px; padding-top: 34px; }
  .notes-right { grid-column: 3; grid-row: 1; justify-self: start; max-width: 230px; padding-top: 34px; }
}

.tool-writeup { margin-top: 64px; }
.tool-writeup .prose { font-size: 17px; }
.data-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--grey);
  margin-top: 28px;
  line-height: 1.6;
}
.data-note a { color: var(--grey); }
.tool-footer { margin-top: 48px; padding-bottom: 72px; }

/* ── The /tools/ hub: one red tile per tool ── */
.tiles {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px 24px;
  margin-top: 44px;
}
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* One composition at every size: the tile keeps its desktop shape and
     everything inside is sized in cqw (1cqw = 1% of the tile's inner width,
     inside the padding), so a phone shows the same tile, scaled. Reference:
     a 308px tile with a 252px inner width. Percentage padding is relative
     to the tile's outer width. */
  container-type: inline-size;
  aspect-ratio: 308 / 300;
  padding: 8.4% 9.1% 9.1%;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 0 var(--red-dark);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 6px 0 var(--red-dark), 0 22px 34px -18px rgba(42, 37, 32, 0.55);
  background: #DE5A46;
}
.tile:active { transform: translateY(-1px); box-shadow: 0 2px 0 var(--red-dark); }
.tile:focus-visible { outline: 2px solid var(--charcoal); outline-offset: 4px; }

.tile-chip {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 11px;
  font-size: 4.37cqw;
  letter-spacing: 0.8cqw;
  text-transform: uppercase;
  color: var(--red);
  background: var(--cream);
  padding: 2cqw 3.6cqw 1.6cqw;
}
.tile-q {
  font-family: var(--serif);
  font-weight: normal;
  font-size: 30px;
  font-size: 13.5cqw;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: #fff;
  margin: 9.5cqw 0 11.1cqw;
  text-wrap: balance;
}
.tile-go {
  font-family: var(--mono);
  font-size: 12px;
  font-size: 4.76cqw;
  letter-spacing: 0.8cqw;
  text-transform: uppercase;
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  gap: 3.2cqw;
}
.tile-go span { display: inline-block; transition: transform 0.18s ease; }
.tile:hover .tile-go span { transform: translateX(6px); }

/* Bottom row: the "go" link on the left, the little drawing on the right,
   sharing a baseline so neither crowds the tile's edge. */
.tile-foot {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 7.9cqw;
}
.tile-foot .tile-go { padding-bottom: 2px; }
.tile-art {
  flex-shrink: 0;
  width: 27cqw;
  height: 27cqw;
  color: var(--paper);
  transition: transform 0.25s ease;
}
.tile:hover .tile-art { transform: rotate(-6deg) scale(1.06); }
.tile-art .bar { transform-box: fill-box; transform-origin: left center; transition: transform 0.3s ease; }
.tile:hover .tile-art .bar { transform: scaleX(0.7); }
.tile:hover .tile-art .bar.b2 { transition-delay: 0.05s; }
.tile:hover .tile-art .bar.b3 { transition-delay: 0.1s; }
.tile-art .day-end { transition: fill 0.2s ease; }
.tile-art .hand { transform-box: view-box; transform-origin: 40px 44px; transition: transform 0.5s ease; }
.tile:hover .tile-art .hand { transform: rotate(150deg); }
.tile-art .coin { transition: transform 0.35s ease; }
.tile:hover .tile-art .coin { transform: translateY(6px); }
.tile:hover .tile-art .day-end { fill: var(--charcoal); }

.tile-dek {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--charcoal-mid);
  text-wrap: pretty;
}
.tile-meta {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--grey);
}
@media (prefers-reduced-motion: reduce) {
  .tile, .tile-art, .tile-art .bar, .tile-art .hand, .tile-art .coin, .tile-go span { transition: none; }
  .tile:hover, .tile:hover .tile-art, .tile:hover .tile-go span, .tile:hover .tile-art .bar, .tile:hover .tile-art .hand, .tile:hover .tile-art .coin { transform: none; }
}

/* ── Shared controls for calculator-style tools ── */
.field-row { display: flex; flex-wrap: wrap; gap: 18px 22px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-grow { flex: 1 1 200px; }
.field label, .field .field-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--charcoal-mid);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}
.field input, .field select {
  font-family: var(--sans);
  font-size: 18px;
  color: var(--charcoal);
  background: var(--cream);
  border: 1px solid var(--grey-light);
  border-radius: 0;
  padding: 11px 13px;
  min-height: 48px;
  width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red); }
.input-money { position: relative; }
.input-money::before {
  content: '£';
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--grey);
  pointer-events: none;
}
.input-money input { padding-left: 28px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 46px; }
.input-suffix span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--grey);
  pointer-events: none;
}

/* "?" tooltips on labels: hover or focus shows the text. */
.tip { position: relative; display: inline-flex; }
.tip button {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid var(--grey);
  background: transparent;
  color: var(--grey);
  font: 700 11px/1 var(--sans);
  cursor: help;
  padding: 0;
}
.tip button:hover, .tip button:focus-visible { border-color: var(--red); color: var(--red); }
.tip [role="tooltip"] {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: 250px;
  background: var(--charcoal);
  color: var(--paper);
  font: 400 13px/1.5 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  padding: 10px 12px;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
  pointer-events: none;
}
.tip:hover [role="tooltip"], .tip:focus-within [role="tooltip"] { opacity: 1; visibility: visible; }
/* On small screens a tooltip sits over its own field instead of floating
   by the "?", so it can never push the page wider than the screen. */
@media (max-width: 560px) {
  .field { position: relative; }
  .field .tip { position: static; }
  .field .tip [role="tooltip"] { left: 0; right: 0; bottom: calc(100% - 18px); transform: none; width: auto; min-width: 0; }
}

.tool-section-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--grey);
  margin: 26px 0 10px;
}

/* Results */
.result { margin-top: 26px; padding-top: 24px; border-top: 1px dashed var(--grey-light); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .result-grid { grid-template-columns: 1fr; } }
.result-box { background: var(--paper); padding: 16px 18px; }
.result-box.go { background: var(--charcoal); color: var(--paper); }
.result-box.warn { background: var(--red); color: #fff; }
.result-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--grey);
}
.result-box.go .result-label, .result-box.warn .result-label { color: rgba(255, 255, 255, 0.72); }
.result-value {
  font-family: var(--serif);
  font-size: clamp(24px, 3.4vw, 30px);
  line-height: 1.15;
  margin-top: 8px;
}
.result-sub { font-size: 14px; margin-top: 6px; color: var(--charcoal-mid); line-height: 1.45; }
.result-box.go .result-sub, .result-box.warn .result-sub { color: rgba(255, 255, 255, 0.8); }
.result-note { margin-top: 16px; font-size: 15px; line-height: 1.55; color: var(--charcoal-mid); }
.result-note strong { color: var(--charcoal); font-weight: 600; }
.result-note.warn { border-left: 3px solid var(--mark-open); padding-left: 12px; }

/* Dated list: one row per day or step. */
.steps { list-style: none; margin-top: 20px; border-top: 1px solid var(--paper-dark); font-size: 15px; }
.steps li {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 10px 2px;
  border-bottom: 1px solid var(--paper-dark);
}
.steps .s-date { font-family: var(--mono); font-size: 13px; color: var(--charcoal-mid); white-space: nowrap; }
.steps .s-what { color: var(--charcoal); line-height: 1.45; }
.steps .s-what small { display: block; color: var(--grey); font-size: 13px; margin-top: 2px; }
.steps .s-tag { font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap; }
.steps .ok .s-tag { color: #5f8f22; }
.steps .soon .s-tag { color: #b9741c; }
.steps .late .s-tag { color: var(--mark-stop); font-weight: 700; }
.steps .late { background: rgba(216, 80, 58, 0.06); }
.steps .mile .s-what { font-weight: 600; }
.steps .today { background: var(--paper); }
.steps .end { background: var(--charcoal); }
.steps .end .s-date, .steps .end .s-what { color: var(--paper); }
.steps .end .s-tag { color: var(--red-soft); font-weight: 700; }
@media (max-width: 520px) {
  .steps { font-size: 14px; }
  .steps li { grid-template-columns: 74px 1fr auto; gap: 8px; }
  .steps .s-date { font-size: 12px; }
  .steps .s-tag { font-size: 10px; letter-spacing: 1px; }
}

.tool-actions { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 18px; align-items: center; }
.btn-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: none;
  border: 0;
  color: var(--red);
  cursor: pointer;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--red-dark); }
.copied { font-family: var(--mono); font-size: 12px; color: var(--grey); }
