/* ==========================================================================
   Toyota Tanzania — base styles for the rebuilt site.
   Loaded after tokens.css, only on pages that use the brand-guideline design.
   Every value comes from the tokens; see TTL Brand Guidelines v1.0.
   ========================================================================== */

@layer ttl-base {

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-brand);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  font-weight: var(--fw-book);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, video, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
/* Headings break into even lines; paragraphs avoid a lone last word. */
h1, h2, h3, h4 { text-wrap: balance; }
p, li, dd, figcaption { text-wrap: pretty; }
/* Browser surfaces in the palette: selection, caret. */
::selection { background: rgb(224 42 41 / 0.2); color: inherit; }
input, textarea { caret-color: var(--ttl-red); }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* Visible focus ring: 2px black, offset 3px (white on dark surfaces). */
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.ttl-on-dark :focus-visible { outline-color: var(--ttl-white); }

.ttl-skip {
  position: absolute; left: var(--space-4); top: -100px; z-index: 1000;
  padding: var(--space-3) var(--space-5); background: var(--ttl-black); color: var(--ttl-white);
  border-radius: var(--radius-pill); font-weight: var(--fw-semibold); text-decoration: none;
}
.ttl-skip:focus { top: var(--space-4); }

/* Pinned to the top-left of its container, so labels inside scrolling strips never widen the page. */
.ttl-visually-hidden {
  position: absolute !important; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Layout ---------- */

.ttl-container {
  width: 100%;
  max-width: calc(var(--container-max) + 2 * var(--page-margin));
  margin-inline: auto;
  padding-inline: var(--page-margin);
}
.ttl-section { padding-block: var(--space-9); }
.ttl-section--tight { padding-block: var(--space-8); }
.ttl-section--alt { background: var(--color-bg-alt); }
.ttl-section--dark { background: var(--color-bg-inverse); color: var(--color-text-inverse); }
@media (max-width: 767px) {
  .ttl-section { padding-block: var(--space-8); }
  .ttl-section--tight { padding-block: var(--space-7); }
}

.ttl-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gutter); }
@media (max-width: 1023px) { .ttl-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (max-width: 767px) { .ttl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- Type scale ---------- */

.ttl-display {
  font-size: var(--fs-display); font-weight: var(--fw-bold); line-height: var(--lh-headline);
  text-transform: uppercase; text-wrap: balance;
}
.ttl-h1 { font-size: var(--fs-h1); font-weight: var(--fw-semibold); line-height: var(--lh-heading); text-wrap: balance; }
.ttl-h2 { font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: var(--lh-heading); text-wrap: balance; }
.ttl-h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); }
.ttl-h4 { font-size: var(--fs-h4); font-weight: var(--fw-semibold); line-height: 1.25; }
.ttl-lead { font-size: var(--fs-body-lg); line-height: var(--lh-body); max-width: 60ch; text-wrap: pretty; }
.ttl-small { font-size: var(--fs-small); }
.ttl-legal { font-size: var(--fs-legal); color: var(--color-text-muted); }
.ttl-muted { color: var(--color-text-muted); }
.ttl-eyebrow {
  font-size: var(--fs-small); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--color-text-muted);
}
.ttl-on-dark .ttl-eyebrow, .ttl-on-dark .ttl-muted { color: var(--ttl-gray-200); }
.ttl-on-dark { font-weight: var(--fw-regular); } /* Regular instead of Book for white text on dark */

/* "Let's Go Places": title case, Semibold italic, only in a headline, a logo or closing body copy. */
.ttl-tagline { font-weight: var(--fw-semibold); font-style: italic; }

.ttl-prose { max-width: 70ch; }
.ttl-prose > * + * { margin-top: var(--space-4); }
.ttl-prose a { color: var(--ttl-black); text-underline-offset: 3px; }

/* ---------- Buttons ---------- */
/* Primary (red): one per view. Secondary (black) and outline: supporting. Text link: tertiary.
   48px minimum height, 16px Semibold, pill radius. */

.ttl-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 0 var(--space-6); border: 2px solid transparent; border-radius: var(--radius-pill);
  font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; isolation: isolate;
  transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), transform 160ms cubic-bezier(.23, 1, .32, 1);
}
/* Press feedback: every button answers the press at once. */
.ttl-btn:active:not([disabled]):not([aria-disabled="true"]) { transform: scale(.97); }
@media (prefers-reduced-motion: reduce) { .ttl-btn:active { transform: none; } }
.ttl-btn::after { content: ''; position: absolute; inset: -2px; border-radius: inherit; background: transparent; transition: background-color var(--dur-fast) var(--ease-standard); z-index: -1; pointer-events: none; }
.ttl-btn--primary { background: var(--ttl-red); color: var(--ttl-white); }
.ttl-btn--primary:hover { background: var(--ttl-red-pressed); }
.ttl-btn--primary:active { background: var(--ttl-red-pressed); }
.ttl-btn--secondary { background: var(--ttl-black); color: var(--ttl-white); }
.ttl-btn--secondary:hover { background: var(--ttl-gray-900); }
.ttl-btn--outline { background: transparent; border-color: var(--ttl-black); color: var(--ttl-black); }
.ttl-btn--outline:hover::after { background: var(--ttl-black-hover); }
.ttl-btn--outline:active::after { background: var(--ttl-black-active); }
.ttl-btn--white { background: var(--ttl-white); color: var(--ttl-black); }
.ttl-btn--white:hover::after { background: var(--ttl-black-hover); }
.ttl-on-dark .ttl-btn--outline { border-color: var(--ttl-white); color: var(--ttl-white); }
.ttl-on-dark .ttl-btn--outline:hover::after { background: rgba(255, 255, 255, 0.12); }
.ttl-btn[disabled], .ttl-btn[aria-disabled="true"] { background: var(--ttl-gray-100); border-color: var(--ttl-gray-100); color: var(--ttl-gray-400); cursor: not-allowed; }
.ttl-btn--sm { min-height: 48px; padding: 0 var(--space-5); }
.ttl-btn--block { width: 100%; }

.ttl-link {
  display: inline-flex; align-items: center; min-height: 44px; gap: var(--space-1);
  font-weight: var(--fw-semibold); color: var(--ttl-black); text-decoration: underline; text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}
.ttl-link:hover { text-decoration-color: var(--ttl-red); }
button.ttl-link { padding: 0; border: 0; background: none; cursor: pointer; }
.ttl-on-dark .ttl-link { color: var(--ttl-white); }

.ttl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); }

/* ---------- Forms ---------- */
/* Always a visible label; errors in text under the field; 16px in inputs (stops mobile zoom). */

/* Fields line up across a row: label, box and hint stack from the top, and every box is one height
   (a neighbour's hint or error never stretches the box). */
.ttl-field { display: grid; gap: var(--space-2); align-content: start; }
.ttl-label { font-size: var(--fs-small); font-weight: var(--fw-semibold); }
.ttl-fixed { display: flex; align-items: center; min-height: 48px; margin: 0; padding: 0 var(--space-4); background: var(--ttl-gray-50, #f5f5f5); border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-weight: var(--fw-semibold); }
.ttl-optional { font-weight: var(--fw-book); color: var(--color-text-muted); }
.ttl-hint { font-size: var(--fs-small); color: var(--color-text-muted); }
.ttl-error { font-size: var(--fs-small); color: var(--ttl-error); }
.ttl-input, .ttl-select, .ttl-textarea {
  width: 100%; min-height: 48px; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--ttl-gray-700); border-radius: var(--radius-sm); background: var(--ttl-white);
  font-size: var(--fs-body); line-height: 1.3;
}
.ttl-input, .ttl-select { height: 48px; }
.ttl-textarea { min-height: 120px; resize: vertical; }
.ttl-select {
  appearance: none; padding-right: var(--space-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-4) center;
}
.ttl-input:focus-visible, .ttl-select:focus-visible, .ttl-textarea:focus-visible { outline-offset: 1px; }
.ttl-input[aria-invalid="true"], .ttl-select[aria-invalid="true"], .ttl-textarea[aria-invalid="true"] { border: 2px solid var(--ttl-error); }
.ttl-check { display: grid; grid-template-columns: 24px 1fr; gap: var(--space-3); align-items: start; font-size: var(--fs-small); }
.ttl-check input { width: 24px; height: 24px; margin: 0; accent-color: var(--ttl-black); }

/* ---------- Cards & chips ---------- */

.ttl-card { background: var(--ttl-white); border: 1px solid var(--color-border); }
.ttl-chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-5);
  border: 1px solid var(--ttl-gray-200); border-radius: var(--radius-pill); background: var(--ttl-white);
  font-weight: var(--fw-semibold); font-size: var(--fs-small); text-decoration: none; color: var(--ttl-black); cursor: pointer;
}
.ttl-chip:hover { border-color: var(--ttl-black); }
.ttl-chip[aria-pressed="true"], .ttl-chip[aria-current="page"] { background: var(--ttl-black); border-color: var(--ttl-black); color: var(--ttl-white); }

/* ---------- Article: page text from the CMS (src/brand/content.js) ---------- */
/* Headings, paragraphs and lists on the type scale; images at their own size up to the column;
   tables that scroll on their own on phones; panels as plain disclosure rows. */

.ttl-article { max-width: 760px; font-size: var(--fs-body); line-height: var(--lh-body); overflow-wrap: break-word; }
.ttl-article > * + * { margin-top: var(--space-4); }
.ttl-article :is(p, li) { max-width: 62ch; }
.ttl-article blockquote :is(p, li) { max-width: 56ch; }
.ttl-article h2 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-heading); margin-top: var(--space-8); text-wrap: balance; }
.ttl-article h3 { font-size: var(--fs-h4); font-weight: var(--fw-semibold); line-height: 1.25; margin-top: var(--space-7); }
.ttl-article h4 { font-size: var(--fs-body-lg); font-weight: var(--fw-semibold); line-height: 1.3; margin-top: var(--space-6); }
.ttl-article > :first-child { margin-top: 0; }
.ttl-article h2 + *, .ttl-article h3 + *, .ttl-article h4 + * { margin-top: var(--space-3); }
.ttl-article ul, .ttl-article ol { padding-left: 1.4em; display: grid; gap: var(--space-2); }
.ttl-article li::marker { color: var(--ttl-red); }
.ttl-article a:not(.ttl-btn) { color: var(--ttl-black); text-decoration: underline; text-underline-offset: 3px; }
.ttl-article a:not(.ttl-btn):hover { text-decoration-color: var(--ttl-red); }
.ttl-article strong { font-weight: var(--fw-semibold); }
.ttl-article figure { margin-block: var(--space-6); }
.ttl-article figure img, .ttl-article p img { width: auto; max-width: 100%; height: auto; }
.ttl-article figure a { display: inline-block; }
/* A picture in a table cell (each tyre in the tyre table): a small thumbnail beside the cell's text. */
.ttl-article td > img { float: left; width: 88px; height: auto; margin-right: var(--space-5); }
.ttl-article td:has(> img)::after { content: ''; display: block; clear: both; }
.ttl-article blockquote { margin-inline: 0; padding: var(--space-5) var(--space-6); background: var(--ttl-gray-50); border-radius: var(--radius-sm); font-size: var(--fs-body-lg); }
.ttl-article .ttl-actions { margin-top: var(--space-5); }
.ttl-article .ttl-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: var(--space-4); margin-block: var(--space-6); }
.ttl-article a.ttl-imgtile {
  display: grid; gap: var(--space-3); align-content: start; padding: var(--space-4);
  border: 1px solid var(--color-border); background: var(--ttl-white); text-decoration: none; font-weight: var(--fw-semibold);
}
.ttl-article a.ttl-imgtile:hover { border-color: var(--ttl-black); text-decoration: none; }
.ttl-article a.ttl-imgtile:hover span { text-decoration: underline; text-underline-offset: 4px; }
.ttl-article a.ttl-imgtile img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.ttl-embed { position: relative; aspect-ratio: 16 / 9; background: var(--ttl-black); margin-block: var(--space-6); }
.ttl-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ttl-table { overflow-x: auto; margin-block: var(--space-6); border: 1px solid var(--color-border); }
.ttl-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.ttl-table th, .ttl-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; min-width: 120px; }
.ttl-table th { background: var(--ttl-gray-50); font-weight: var(--fw-semibold); }
.ttl-table tr:last-child > * { border-bottom: 0; }
.ttl-table td > * + * { margin-top: var(--space-2); }
.ttl-article details { border-top: 1px solid var(--color-border); }
.ttl-article details:last-of-type { border-bottom: 1px solid var(--color-border); }
.ttl-article details + details { margin-top: 0; }
.ttl-article summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: 56px; padding-block: var(--space-3); font-weight: var(--fw-semibold); cursor: pointer; list-style: none;
}
.ttl-article summary::-webkit-details-marker { display: none; }
.ttl-article summary::after {
  content: ''; flex: none; width: 12px; height: 12px; margin-right: var(--space-2);
  border-right: 2px solid var(--ttl-black); border-bottom: 2px solid var(--ttl-black); transform: rotate(45deg) translateY(-3px);
  transition: transform var(--dur-fast) var(--ease-standard);
}
.ttl-article details[open] > summary::after { transform: rotate(-135deg) translateY(-3px); }
@media (prefers-reduced-motion: reduce) { .ttl-article summary::after { transition: none; } }
.ttl-article details > :not(summary) { margin-bottom: var(--space-4); }
.ttl-article details > * + * { margin-top: var(--space-3); }

.ttl-notice { padding: var(--space-4) var(--space-5); border: 1px solid var(--ttl-gray-200); border-radius: var(--radius-sm); background: var(--ttl-gray-50); }
.ttl-notice--success { border-color: var(--ttl-success); }
.ttl-notice--error { border-color: var(--ttl-error); }
}
