/* Portfolio: the "Tools to try" page and every tool page under /portfolio/. Loaded after /styles.css and uses
   its tokens. Tool pages share the tl- classes, so each new tool only adds its own markup and script. */

/* ---------- Portfolio page ---------- */
.pf-head { padding-top: clamp(40px, 7vw, 88px); padding-bottom: clamp(28px, 4vw, 48px); }
.pf-head h1 { max-width: none; }
.pf-head .lede { max-width: 54ch; margin-bottom: 0; }

/* Cards: three across, two on tablets, one on phones. The title link covers the whole card. */
.pf-grid { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.pf-card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); transition: border-color 0.15s; }
.pf-card:hover { border-color: var(--line-strong); }
.pf-card:has(a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.pf-thumb { aspect-ratio: 16 / 10; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--paper); }
.pf-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.pf-body { display: flex; flex-direction: column; gap: 0.55rem; padding: 20px 22px 18px; flex: 1; }
.pf-tag { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.pf-card h3 { font-size: 1.3rem; font-stretch: 110%; }
.pf-card h3 a { text-decoration: none; outline: none; }
.pf-card h3 a::after { content: ''; position: absolute; inset: 0; }
.pf-desc { color: var(--muted); font-size: 0.98rem; }
.pf-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 0.9rem; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.02em; color: var(--muted); }
.pf-go { color: var(--ink); white-space: nowrap; }
.pf-card:hover .pf-go { color: var(--accent); }
.pf-cta { margin-block: clamp(48px, 7vw, 88px); }

/* Thumbnails come in a light and a dark version, following the site's theme switch. */
.only-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-light { display: none !important; }
  :root:not([data-theme="light"]) .only-dark { display: block !important; }
}
:root[data-theme="dark"] .only-light { display: none !important; }
:root[data-theme="dark"] .only-dark { display: block !important; }

/* ---------- Tool pages ---------- */
.tl { padding-bottom: clamp(48px, 7vw, 88px); }
.tl-head { padding-top: clamp(32px, 5vw, 64px); padding-bottom: clamp(24px, 3vw, 36px); }
.tl-head h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); max-width: 24ch; }
.tl-head .lede { max-width: 62ch; margin: 1.1rem 0 0; }
.tl-head .built { margin-top: 1.2rem; }
.crumb { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 1.2rem; }
.crumb a { color: var(--accent); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb span { margin-inline: 0.35em; }

.tl-form { padding: clamp(20px, 3vw, 36px); }
.tl-sec { border: 0; margin: 0; padding: 0 0 28px; min-width: 0; }
.tl-sec + .tl-sec { border-top: 1px solid var(--line); padding-top: 28px; }
.tl-sec > legend { float: left; width: 100%; padding: 0; margin-bottom: 1rem; display: flex; align-items: baseline; gap: 12px; font-weight: 600; font-stretch: 108%; font-size: 1.22rem; }
.tl-sec > legend b { font-family: var(--mono); font-weight: 500; font-size: 0.85rem; color: var(--accent); font-stretch: 100%; }
.tl-sec > legend + * { clear: both; }
.tl-intro { color: var(--muted); font-size: 0.95rem; max-width: 68ch; margin-bottom: 1rem; }
.tl-intro strong { color: var(--ink); }
.tl-sub { font-size: 0.95rem; font-weight: 600; margin: 1.3rem 0 0.55rem; }
.tl-sub .muted { color: var(--muted); font-weight: 400; }
.tl-sec > legend + .tl-sub, .tl-sec > legend + div > .tl-sub:first-child { margin-top: 0; }

/* One choice from several (aria-pressed buttons), and on/off toggles: the same cut-corner tick as the
   AI Opportunity Finder's answers. */
.tl-seg, .tl-togs { display: flex; flex-wrap: wrap; gap: 6px; max-width: 820px; }
.tl-togs { gap: 8px; }
.tl-seg button, .tl-tog {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
.tl-seg button::before, .tl-tog::before {
  content: '';
  flex: none;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--line-strong);
  clip-path: polygon(0 0, 70% 0, 100% 30%, 100% 100%, 30% 100%, 0 70%);
}
.tl-seg button:hover, .tl-tog:hover { border-color: var(--line-strong); }
.tl-seg button[aria-pressed="true"], .tl-tog[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.tl-seg button[aria-pressed="true"]::before, .tl-tog[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }

.tl-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; max-width: 860px; margin-top: 1rem; }
.tl-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 580px; }
.tl-row.one { grid-template-columns: minmax(0, 1fr); max-width: 380px; }
.tl-field { display: flex; flex-direction: column; min-width: 0; }
.tl-field label { flex: 1 0 auto; margin-bottom: 6px; font-size: 0.9rem; color: var(--muted); line-height: 1.4; }
.tl-in { position: relative; }
.tl-in input, .tl-field select {
  width: 100%;
  min-height: 46px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.tl-field select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23879099' stroke-width='1.6' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
.tl-in input:focus, .tl-field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.tl-in.gbp input { padding-left: 1.75rem; }
.tl-in.gbp::before { content: '£'; position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.tl-in .suffix { position: absolute; right: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.9rem; pointer-events: none; }
.tl-in.has-suffix input { padding-right: 4.4rem; }
.tl-hint { color: var(--muted); font-size: 0.88rem; line-height: 1.5; margin-top: 0.7rem; max-width: 78ch; }
.tl-hint strong { color: var(--ink); font-weight: 600; }
.tl-reveal { margin-top: 1rem; }

.tl-go { margin-top: 28px; width: 100%; max-width: 420px; gap: 10px; }
.tl-go.is-current { color: var(--ink); }
.tl-go.is-current::before { background: var(--accent-tint); }
.tl-go[disabled] { cursor: progress; }
.tl-go .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: tl-spin 0.7s linear infinite; }
@keyframes tl-spin { to { transform: rotate(360deg); } }
.tl-engine-down { margin-top: 1rem; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--accent-tint); }

/* Results */
.tl-results { margin-top: clamp(32px, 5vw, 56px); scroll-margin-top: 84px; transition: opacity 0.25s; }
.tl-results.stale { opacity: 0.4; }
.tl-sum { padding: clamp(20px, 3vw, 32px); }
.tl-sum h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); outline: none; }
.tl-lead { margin: 0.8rem 0 1.4rem; max-width: 72ch; }
.tl-lead strong { color: var(--accent); }
.tl-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 0; padding-top: 20px; border-top: 1px solid var(--line-strong); }
.tl-tiles dt { font-size: clamp(1.7rem, 3vw, 2.4rem); font-weight: 600; font-stretch: 116%; letter-spacing: -0.02em; color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tl-tiles dd { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; max-width: 32ch; }
.tl-note { color: var(--muted); font-size: 0.85rem; margin-top: 1.2rem; max-width: 80ch; }
.tl-h2 { margin: clamp(32px, 5vw, 48px) 0 0.6rem; font-size: clamp(1.4rem, 2.4vw, 1.8rem); font-stretch: 112%; }
.tl-key { color: var(--muted); font-size: 0.93rem; max-width: 82ch; margin-bottom: 1.4rem; }
.tl-key strong { color: var(--ink); }
.tl-empty { color: var(--muted); }

.tl-cards { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tl-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); }
.tl-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tl-card h3 { font-size: 1.12rem; font-stretch: 106%; }
.tl-card h3 span { font-family: var(--mono); font-weight: 500; font-size: 0.85rem; color: var(--muted); margin-right: 0.5rem; font-stretch: 100%; }
.tl-badge { flex: none; padding: 3px 8px; border: 1px solid var(--line-strong); font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.tl-badge.back { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tl-badge.now { background: var(--accent-tint); border-color: var(--accent); }
.tl-badge.check { color: var(--muted); border-style: dashed; }
.tl-role { color: var(--muted); font-size: 0.9rem; }
.tl-val { font-size: 1.6rem; font-weight: 600; font-stretch: 112%; line-height: 1.15; color: var(--accent); font-variant-numeric: tabular-nums; }
.tl-val small { margin-left: 0.4rem; font-size: 0.85rem; font-weight: 400; font-stretch: 100%; color: var(--muted); }
.tl-why { font-size: 0.95rem; }
.tl-how { margin-top: auto; padding-top: 0.8rem; border-top: 1px solid var(--line); font-size: 0.88rem; line-height: 1.55; color: var(--muted); }
.tl-how strong { color: var(--ink); font-weight: 600; }
.tl-aside { margin-top: 20px; padding: 16px 20px; border-left: 3px solid var(--accent); background: var(--accent-tint); font-size: 0.93rem; max-width: 90ch; }

.tl-steps { list-style: none; counter-reset: st; border-top: 1px solid var(--line-strong); }
.tl-steps li { counter-increment: st; display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); gap: 2px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.tl-steps li::before { content: '0' counter(st); grid-row: span 2; padding-top: 2px; font-family: var(--mono); color: var(--accent); }
.tl-steps b { font-weight: 600; }
.tl-steps p { color: var(--muted); font-size: 0.93rem; max-width: 80ch; }
.tl-actions { margin-top: 24px; }
.tl-disclaimer { margin-top: clamp(40px, 6vw, 64px); padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; line-height: 1.65; max-width: 110ch; }
.tl-disclaimer p + p { margin-top: 0.7rem; }
.tl-disclaimer strong { color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .tl-results:not(.stale) .tl-in-view { animation: tl-rise 0.45s ease both; }
}
@keyframes tl-rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .tl-go .spin { animation: none; } }

@media (max-width: 1040px) {
  .pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .tl-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tl-cards, .tl-tiles { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .pf-grid, .tl-row, .tl-row.two { grid-template-columns: minmax(0, 1fr); }
  .tl-seg { flex-direction: column; }
  .tl-seg button { width: 100%; }
  .tl-go { max-width: none; }
  .tl-card-top { flex-direction: column-reverse; gap: 8px; }
}

/* Save as PDF: the results only, on the light palette set in /styles.css */
@media print {
  .crumb, .tl-head .lede, .tl-head .built, .tl-form, .tl-go, .tl-actions, .tl-engine-down { display: none !important; }
  .tl-head { padding: 0 0 6px; }
  .tl-head h1 { font-size: 15pt; max-width: none; }
  .tl-results { margin-top: 6px; opacity: 1 !important; }
  .tl-sum { padding: 10px 12px; border: 1px solid var(--line); }
  .tl-sum h2 { font-size: 12pt; }
  .tl-lead { margin: 4px 0 8px; font-size: 9.5pt; }
  .tl-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 8px; }
  .tl-tiles dt { font-size: 15pt; }
  .tl-tiles dd { font-size: 8pt; }
  .tl-h2 { font-size: 12pt; margin: 12px 0 4px; }
  .tl-key, .tl-note { font-size: 8pt; }
  .tl-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tl-card { padding: 8px 10px; break-inside: avoid; }
  .tl-card h3 { font-size: 10pt; }
  .tl-val { font-size: 13pt; }
  .tl-why, .tl-role, .tl-how { font-size: 8.5pt; }
  .tl-steps li { padding: 5px 0; break-inside: avoid; }
  .tl-steps p { font-size: 8.5pt; }
  .tl-disclaimer { font-size: 7.5pt; margin-top: 12px; padding-top: 8px; }
}
