@import url('./tokens.css');

/* Opt-in classes. No body reset, global control styling or application state. */
.tm-scope { color: var(--tm-text); font-family: var(--tm-font-sans); font-size: var(--tm-font-size-body); line-height: var(--tm-font-line-height-body); font-optical-sizing: auto; font-synthesis: none; }
/* Symbol beside a product name. The lockup owns the name's text size: every direct-child image is a symbol 1.5 × that
   size, the gap is 0.5 ×, and they are centered. A font-size on the lockup, or a type role on the same element (the
   roles come later in this file), sets the size for all of them. No color, weight or semantics. */
.tm-lockup { display: inline-flex; align-items: center; gap: .5em; font-size: var(--tm-font-size-lead); }
.tm-lockup > :is(img, svg) { flex: none; inline-size: 1.5em; block-size: 1.5em; }
.tm-lockup .tm-product-name { font-size: inherit; }
/* Optional type roles preserve semantic headings and application layout. */
.tm-title { font-size: var(--tm-font-size-title); line-height: var(--tm-font-line-height-heading); font-weight: var(--tm-font-weight-strong); letter-spacing: -.025em; }
.tm-heading, .tm-product-name { font-size: var(--tm-font-size-lead); line-height: 1.4; font-weight: var(--tm-font-weight-strong); }
.tm-body { font-size: var(--tm-font-size-body); line-height: var(--tm-font-line-height-reading); font-weight: var(--tm-font-weight-regular); }
.tm-caption { font-size: var(--tm-font-size-caption); color: var(--tm-muted); }
.tm-title:lang(ja), .tm-heading:lang(ja) { font-weight: var(--tm-font-weight-japanese-strong); line-height: 1.6; letter-spacing: normal; }
.tm-body:lang(ja) { line-height: var(--tm-font-line-height-japanese); }
/* Unavailable = native :disabled or [aria-disabled="true"] on the same control (e.g. a busy action that
   keeps focus). Both get the neutral resting look and lose hover, press and light; the focus outline stays.
   aria-busy alone stays interactive. Apps still ignore activation of an aria-disabled control. */
/* Own control geometry without requiring a consuming app's global reset. */
.tm-button, .tm-tabs > [role="tab"] { box-sizing: border-box; }
.tm-button { position: relative; isolation: isolate; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: var(--tm-space-2); min-height: var(--tm-control-min-height); border: 1px solid transparent; border-radius: var(--tm-radius-control); padding: var(--tm-space-2) var(--tm-space-4); font: inherit; font-weight: 650; text-decoration: none; color: var(--tm-on-action); background: var(--tm-action); cursor: pointer; transition: background-color var(--tm-motion-normal) var(--tm-motion-ease), transform var(--tm-motion-settle) var(--tm-motion-ease); }
/* A single passing light on interaction; the resting fill remains flat. */
.tm-button::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(110deg, transparent 15%, #FFFFFF33 48%, transparent 80%); transform: translateX(-110%); opacity: 0; }
.tm-button:focus-visible:not(:disabled, [aria-disabled="true"])::before { animation: tm-action-light var(--tm-motion-sweep) var(--tm-motion-ease); }
.tm-button--secondary { color: var(--tm-text); background: var(--tm-surface); border-color: var(--tm-border); }
.tm-button--quiet { color: var(--tm-text); background: transparent; }
.tm-button--secondary::before, .tm-button--quiet::before, .tm-button--scene::before { display: none; }
.tm-button--secondary:focus-visible:not(:disabled, [aria-disabled="true"]), .tm-button--quiet:focus-visible:not(:disabled, [aria-disabled="true"]) { background: color-mix(in srgb, var(--tm-text) 6%, var(--tm-surface)); }
.tm-button:is(:disabled, [aria-disabled="true"]) { color: var(--tm-muted); background: color-mix(in srgb, var(--tm-text) 6%, var(--tm-surface)); cursor: not-allowed; opacity: 1; }
/* Optional app-owned scene, with the same native control and focus contract.
   Theme the scene and label together; the outer button keeps the page's focus. */
.tm-button--scene { border: 0; background: var(--tm-surface); }
.tm-button__scene { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; color: var(--tm-text); background: var(--tm-brand-body, var(--tm-background)); pointer-events: none; }
.tm-button--scene > .tm-button__label { position: relative; z-index: 1; color: var(--tm-text); }
.tm-button__art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tm-button--scene:is(:disabled, [aria-disabled="true"]) > .tm-button__scene { background: inherit; }
.tm-button--scene:is(:disabled, [aria-disabled="true"]) > .tm-button__label { color: inherit; }
.tm-button--scene:is(:disabled, [aria-disabled="true"]) .tm-button__art { visibility: hidden; }
@keyframes tm-action-light { 0% { transform: translateX(-110%); opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { transform: translateX(110%); opacity: 0; } }

.tm-button:focus-visible, .tm-input:focus-visible, .tm-link:focus-visible, .tm-interactive:focus-visible { outline: var(--tm-control-focus-width) solid var(--tm-focus); outline-offset: var(--tm-control-focus-offset); }
.tm-field { display: grid; gap: var(--tm-space-2); }
.tm-label { font-weight: 650; }
.tm-input { width: 100%; min-height: var(--tm-control-min-height); padding: var(--tm-space-2) var(--tm-space-3); border: 1px solid var(--tm-border); border-radius: var(--tm-radius-control); background: var(--tm-surface); color: var(--tm-text); font: inherit; box-sizing: border-box; transition: background-color var(--tm-motion-normal) var(--tm-motion-ease), border-color var(--tm-motion-normal) var(--tm-motion-ease); }
.tm-input:focus { border-color: var(--tm-focus); background: color-mix(in srgb, var(--tm-text) 4%, var(--tm-surface)); }
/* The accepted underline field, with optional app-owned clear action. */
.tm-input-group { display: flex; position: relative; align-items: center; border-bottom: 1px solid var(--tm-border); border-radius: 6px 6px 0 0; background: color-mix(in srgb, var(--tm-text) 5%, var(--tm-surface)); transition: background-color var(--tm-motion-normal) ease; }
.tm-input-group:focus-within { background: color-mix(in srgb, var(--tm-text) 7%, var(--tm-surface)); }
.tm-input-group:has(input:focus-visible) { outline: 2px solid var(--tm-focus); outline-offset: 3px; }
.tm-input-group > input { box-sizing: border-box; width: 100%; min-width: 0; min-height: max(46px, var(--tm-control-min-height)); padding: 10px 12px; border: 0; border-radius: 6px; outline: none; background: transparent; color: var(--tm-text); font: inherit; }
.tm-input-group > button { box-sizing: border-box; display: grid; place-items: center; flex: none; width: var(--tm-control-min-height); height: var(--tm-control-min-height); border: 0; border-radius: 4px; background: transparent; color: var(--tm-muted); cursor: pointer; }
.tm-input-group > button:is(:disabled, [aria-disabled="true"]) { opacity: .4; cursor: default; }
.tm-input-group > button:focus-visible { outline: 2px solid var(--tm-focus); outline-offset: 3px; }
.tm-input-group::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--tm-brand-accent, var(--tm-action)); transform: scaleX(0); transform-origin: left; transition: transform var(--tm-motion-normal) var(--tm-motion-ease); pointer-events: none; }
.tm-input-group:focus-within::after { transform: scaleX(1); }
.tm-input-group:has([aria-invalid="true"]) { border-color: var(--tm-text); }
.tm-hint { color: var(--tm-muted); font-size: var(--tm-font-size-small); }
.tm-link { color: var(--tm-link); text-underline-offset: .2em; transition: text-underline-offset var(--tm-motion-normal) var(--tm-motion-ease), text-decoration-color var(--tm-motion-normal) var(--tm-motion-ease), opacity var(--tm-motion-fast) ease; }
.tm-link:focus-visible { text-underline-offset: .35em; text-decoration-color: var(--tm-action); }
.tm-link:active { text-underline-offset: .14em; text-decoration-thickness: 2px; }
/* Quiet actions, links in navigation, native choice labels and disclosures. */
.tm-interactive { border-radius: 6px; transition: background-color var(--tm-motion-normal) var(--tm-motion-ease), transform var(--tm-motion-settle) var(--tm-motion-ease); }
.tm-interactive:focus-visible:not(:disabled, [aria-disabled="true"]):not(:has(:disabled, [aria-disabled="true"])) { background-color: color-mix(in srgb, var(--tm-text) 6%, transparent); }
.tm-surface { background: var(--tm-surface); border-radius: var(--tm-radius-surface); padding: var(--tm-space-6); }
.tm-stack { display: grid; gap: var(--tm-space-4); }
.tm-inline { display: flex; align-items: center; gap: var(--tm-space-3); flex-wrap: wrap; }

/* Native checkboxes retain browser semantics and app-owned state. Labels give
   the small visual controls a full-size target; never remove the native input. */
.tm-choice { display: flex; align-items: center; justify-content: space-between; gap: var(--tm-space-4); min-height: var(--tm-control-min-height); cursor: pointer; }
.tm-choice:has(input:is(:disabled, [aria-disabled="true"])) { cursor: default; color: var(--tm-muted); background: transparent; transform: none; }
.tm-checkbox { box-sizing: border-box; appearance: none; display: grid; place-items: center; flex: none; width: 18px; height: 18px; margin: 0; border: 1px solid var(--tm-border); border-radius: 4px; background: var(--tm-surface); color: var(--tm-focus); cursor: pointer; transition: background-color var(--tm-motion-normal) ease, transform var(--tm-motion-fast) var(--tm-motion-ease); }
.tm-checkbox::before { box-sizing: border-box; content: ''; width: 8px; height: 5px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; opacity: 0; transform: translateY(-1px) rotate(-45deg) scale(.8); transition: transform var(--tm-motion-fast) var(--tm-motion-ease), opacity var(--tm-motion-fast) ease; }
.tm-checkbox:checked { background: var(--tm-action); color: var(--tm-on-action); border-color: var(--tm-focus); }
.tm-checkbox:checked::before { opacity: 1; transform: translateY(-1px) rotate(-45deg) scale(1); }
.tm-checkbox:focus-visible { outline: 2px solid var(--tm-focus); outline-offset: 3px; }
.tm-checkbox:is(:disabled, [aria-disabled="true"]) { opacity: 1; color: var(--tm-muted); background: var(--tm-surface); cursor: default; }
.tm-choice:active .tm-checkbox:not(:disabled, [aria-disabled="true"]) { transform: scale(.88); }
.tm-switch { box-sizing: border-box; width: 40px; height: 24px; position: relative; flex: none; }
.tm-switch > input { position: absolute; margin: 0; inset: -10px -2px; width: 44px; height: 44px; opacity: 0; cursor: pointer; z-index: 1; }
.tm-switch > span { box-sizing: border-box; display: block; height: 24px; border: 1px solid var(--tm-border); border-radius: 99px; padding: 2px; background: #78838B; transition: background-color var(--tm-motion-normal) ease; }
.tm-switch > span::after { box-sizing: border-box; content: ''; display: block; width: 18px; height: 18px; border-radius: 50%; background: #FFFFFF; transition: transform var(--tm-motion-settle) var(--tm-motion-ease), width var(--tm-motion-fast) ease, background-color var(--tm-motion-fast) ease; }
.tm-switch > input:checked + span { background: var(--tm-brand-body, var(--tm-text)); }
.tm-switch > input:checked + span::after { transform: translateX(16px); background: var(--tm-brand-accent, var(--tm-on-action)); }
.tm-switch > input:focus-visible + span { outline: 2px solid var(--tm-focus); outline-offset: 4px; }
.tm-switch > input:active:not(:disabled, [aria-disabled="true"]) + span::after { width: 22px; }
.tm-switch > input:checked:active:not(:disabled, [aria-disabled="true"]) + span::after { transform: translateX(12px); }
.tm-switch > input:is(:disabled, [aria-disabled="true"]) { cursor: default; }
.tm-switch > input:is(:disabled, [aria-disabled="true"]) + span { background: var(--tm-surface); }
.tm-switch > input:is(:disabled, [aria-disabled="true"]) + span::after { background: var(--tm-muted); }

/* Apps own selection, ARIA and keyboard behavior; these values position the marker. */
.tm-tabs { --tm-tabs-count: 1; --tm-tabs-index: 0; display: grid; grid-template-columns: repeat(var(--tm-tabs-count), minmax(0, 1fr)); position: relative; }
.tm-tabs::after { content: ''; position: absolute; left: 0; bottom: 1px; width: calc(100% / var(--tm-tabs-count)); height: 2px; background: var(--tm-brand-accent, var(--tm-action)); clip-path: inset(0 max(0px, calc(50% - 17px))); transform: translateX(calc(var(--tm-tabs-index) * 100%)); transition: transform var(--tm-motion-settle) var(--tm-motion-ease); pointer-events: none; }
.tm-tabs > [role="tab"] { display: flex; align-items: center; justify-content: center; min-height: var(--tm-control-min-height); border: 0; padding: 10px; background: transparent; color: var(--tm-muted); font: inherit; font-size: 13px; line-height: 1.4; border-radius: 4px; cursor: pointer; transition: color var(--tm-motion-fast) ease, background-color var(--tm-motion-normal) ease, transform var(--tm-motion-settle) var(--tm-motion-ease); }
.tm-tabs > [role="tab"][aria-selected="true"] { color: var(--tm-text); font-weight: 650; }
.tm-tabs > [role="tab"]:focus-visible { outline: var(--tm-control-focus-width) solid var(--tm-focus); outline-offset: var(--tm-control-focus-offset); background: color-mix(in srgb, var(--tm-text) 6%, transparent); }

/* Restore native hidden behavior only where TM sets display. Keep the browser's
   separate hidden-until-found behavior and app-owned display rules intact. */
:is(.tm-lockup, .tm-button, .tm-field, .tm-input-group, .tm-input-group > button, .tm-stack, .tm-inline, .tm-choice, .tm-checkbox, .tm-switch > span, .tm-tabs, .tm-tabs > [role="tab"])[hidden]:not([hidden="until-found" i]) { display: none; }

@media (hover: hover) {
  .tm-button:hover:not(:disabled, [aria-disabled="true"]) { transform: translateY(-2px); background-color: color-mix(in srgb, var(--tm-action) 93%, #FFFFFF); }
  .tm-button:hover:not(:disabled, [aria-disabled="true"])::before { animation: tm-action-light var(--tm-motion-sweep) var(--tm-motion-ease); }
  .tm-button--secondary:hover:not(:disabled, [aria-disabled="true"]), .tm-button--quiet:hover:not(:disabled, [aria-disabled="true"]) { background: color-mix(in srgb, var(--tm-text) 6%, var(--tm-surface)); }
  .tm-button--scene:hover:not(:disabled, [aria-disabled="true"]) { transform: none; background: var(--tm-surface); }
  .tm-input:hover:not(:disabled, [aria-disabled="true"]) { border-color: var(--tm-focus); background-color: color-mix(in srgb, var(--tm-text) 3%, var(--tm-surface)); }
  .tm-input-group:hover { background-color: color-mix(in srgb, var(--tm-text) 7%, var(--tm-surface)); }
  .tm-input-group > button:hover:not(:disabled, [aria-disabled="true"]) { color: var(--tm-text); }
  .tm-choice:hover .tm-checkbox:not(:checked):not(:disabled, [aria-disabled="true"]) { background-color: color-mix(in srgb, var(--tm-text) 6%, var(--tm-surface)); }
  .tm-choice:hover .tm-checkbox:checked:not(:disabled, [aria-disabled="true"]) { background-color: color-mix(in srgb, var(--tm-action) 93%, #FFFFFF); }
  .tm-choice:hover .tm-switch > input:not(:disabled, [aria-disabled="true"]) + span { background-color: color-mix(in srgb, #FFFFFF 8%, #78838B); }
  .tm-choice:hover .tm-switch > input:checked:not(:disabled, [aria-disabled="true"]) + span { background-color: color-mix(in srgb, #FFFFFF 8%, var(--tm-brand-body, var(--tm-text))); }
  .tm-interactive:hover:not(:disabled, [aria-disabled="true"]):not(:has(:disabled, [aria-disabled="true"])) { background-color: color-mix(in srgb, var(--tm-text) 6%, transparent); transform: translateY(-1px); }
  .tm-link:hover { text-underline-offset: .35em; text-decoration-color: var(--tm-action); }
  .tm-tabs > [role="tab"]:hover:not(:disabled, [aria-disabled="true"]) { color: var(--tm-text); background-color: color-mix(in srgb, var(--tm-text) 6%, transparent); transform: translateY(-1px); }
}
.tm-button:active:not(:disabled, [aria-disabled="true"]) { transform: translateY(1px) scale(.97); transition-duration: var(--tm-motion-fast); }
.tm-interactive:active:not(:disabled, [aria-disabled="true"]):not(:has(:disabled, [aria-disabled="true"])), .tm-tabs > [role="tab"]:active:not(:disabled, [aria-disabled="true"]) { transform: scale(.97); background-color: color-mix(in srgb, var(--tm-text) 10%, transparent); transition-duration: var(--tm-motion-fast); }
@media (prefers-reduced-motion: reduce) {
  .tm-button, .tm-button::before, .tm-input, .tm-input-group, .tm-input-group::after, .tm-checkbox, .tm-checkbox::before, .tm-switch > span, .tm-switch > span::after, .tm-link, .tm-interactive, .tm-tabs::after, .tm-tabs > [role="tab"] { transition: none; animation: none !important; }
  .tm-button:hover:not(:disabled, [aria-disabled="true"]), .tm-button:active:not(:disabled, [aria-disabled="true"]), .tm-interactive:hover:not(:disabled, [aria-disabled="true"]):not(:has(:disabled, [aria-disabled="true"])), .tm-interactive:active:not(:disabled, [aria-disabled="true"]):not(:has(:disabled, [aria-disabled="true"])), .tm-tabs > [role="tab"]:hover:not(:disabled, [aria-disabled="true"]), .tm-tabs > [role="tab"]:active:not(:disabled, [aria-disabled="true"]) { transform: none; }
  .tm-choice:active .tm-checkbox:not(:disabled, [aria-disabled="true"]) { transform: none; }
  .tm-switch > input:active:not(:disabled, [aria-disabled="true"]) + span::after { width: 18px; }
  .tm-switch > input:checked:active:not(:disabled, [aria-disabled="true"]) + span::after { transform: translateX(16px); }
}
@media (forced-colors: active) {
  .tm-button { border-color: ButtonText; }
  .tm-button::before { display: none; }
  .tm-button--scene { border: 1px solid ButtonText; background: ButtonFace; }
  .tm-button--scene > .tm-button__scene { background: ButtonFace; }
  .tm-button--scene > .tm-button__label { color: ButtonText; }
  .tm-button--scene:is(:disabled, [aria-disabled="true"]) > .tm-button__label { color: GrayText; }
  .tm-button__art { display: none; }
  .tm-checkbox { appearance: auto; }
  .tm-checkbox::before { display: none; }
  .tm-switch > input { opacity: 1; position: static; width: 24px; height: 24px; }
  .tm-switch > span { display: none; }
  .tm-input-group { border-color: ButtonText; }
  .tm-input-group::after { background: Highlight; }
  .tm-input-group:has(input:focus-visible), .tm-input-group > button:focus-visible, .tm-checkbox:focus-visible, .tm-switch > input:focus-visible { outline: 2px solid Highlight; outline-offset: 3px; }
  .tm-button:is(:disabled, [aria-disabled="true"]) { color: GrayText; border-color: GrayText; }
  /* The browser greys only native disabled; give aria-disabled the same system color. Native checkbox and
     switch drawing stays the browser's, so an aria-disabled one looks available here (see adoption). */
  :is(.tm-input-group > button, .tm-interactive, .tm-tabs > [role="tab"]):is(:disabled, [aria-disabled="true"]) { color: GrayText; border-color: GrayText; }
  .tm-tabs::after { background: Highlight; }
  .tm-tabs > [role="tab"][aria-selected="true"] { text-decoration: underline; text-decoration-color: ButtonText; }
  .tm-button:focus-visible, .tm-input:focus-visible, .tm-link:focus-visible, .tm-interactive:focus-visible, .tm-tabs > [role="tab"]:focus-visible { outline-color: Highlight; }
}
