/*
 * Taste calibration: how every step adapts to the screen and the traveller's settings (height, width, text size,
 * motion, transparency, contrast). Linked last, after taste-calibration-ready.css: these override the other parts.
 */

/* Phones with little height: a smaller hero and chips keep every person and the button in view. */
@media (max-height: 700px) {
  .tc-hero { height: 214px; margin: 12px 0 10px; }
  .tc-hero-card { scale: 0.78; transform-origin: top center; }
  .tc-relations { margin-top: 16px; }
  .tc-relations .tc-chip { min-height: 44px; }
}

/* A large centred sheet from tablet width on. */
@media (min-width: 768px) {
  dialog.tc {
    --tc-pad: 32px;
    width: min(1104px, calc(100vw - 48px));
    height: min(900px, calc(100vh - 48px));
    height: min(900px, calc(100dvh - 48px));
    margin: auto;
    border-radius: 28px;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  .tc-top { padding-top: 14px; padding-right: 20px; }
  .tc-title { font-size: 2rem; line-height: 2.375rem; }
  .tc-intro { text-align: center; }
  .tc-intro .tc-relations { justify-content: center; }
  .tc-footer .tc-column { max-width: calc(440px + 2 * var(--tc-pad)); }
  .tc-grid-head .tc-wide { align-items: center; }
  .tc-tabs, .tc-learn { width: min(100%, 640px); }
  .tc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .tc-bar { left: 50%; right: auto; width: min(640px, calc(100% - 28px)); transform: translateX(-50%); }
}
@media (min-width: 1100px) {
  .tc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Large text: one column and no decorative hero. */
@media (max-width: 22em) {
  .tc-grid { grid-template-columns: minmax(0, 1fr); }
  .tc-hero { display: none; }
}

/* Motion: hero fan, heart pop, neighbour tiles scaling in, the "More like this" badge fading away. */
@media (prefers-reduced-motion: no-preference) {
  .tc-hero-card { animation: tc-rise 420ms cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }
  .tc-tile.is-popping .tc-heart .tc-icon { animation: tc-pop 250ms cubic-bezier(0.3, 1.6, 0.5, 1); }
  .tc-tile.is-new { animation: tc-in 220ms ease-out both; }
}
@media (prefers-reduced-motion: reduce) {
  .tc-tile.is-new { animation: tc-fade 220ms ease-out both; }
  .tc-dots li, .tc-chip, .tc-tile, .tc-heart, .tc-cta { transition: none; }
  .tc-hero-card { animation: tc-fade 220ms ease-out both; }
}
@keyframes tc-spin { to { transform: rotate(360deg); } }
@keyframes tc-pop { 0% { transform: scale(1); } 50% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes tc-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes tc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tc-rise { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: none; } }
@keyframes tc-badge { 0% { opacity: 0; } 8% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; } }

/* Reduce Transparency / more contrast: opaque surfaces with a visible border instead of glass. */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .tc-chip, .tc-tabs, .tc-learn, .tc-tile, .tc-hero-card, .tc-pick-list, .tc-bar, .tc-heart {
    background: var(--tc-solid);
    border: 1px solid var(--tc-solid-line);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tc-chip[aria-pressed="true"] { background: #0f3d63; border-color: var(--tc-sky); }
  .tc-tile[aria-pressed="true"] { border: 2px solid var(--tc-sky); box-shadow: none; }
  .tc-tile[aria-pressed="true"] .tc-heart { background: #fff; }
  .tc-grid-step::after { background: linear-gradient(180deg, rgba(17, 28, 51, 0), #111c33 70%); }
}

/* Windows high contrast: system colours carry the state. */
@media (forced-colors: active) {
  .tc-chip, .tc-tabs, .tc-learn, .tc-tile, .tc-pick-list, .tc-bar, .tc-cta, .tc-heart, .tc-saving, .tc-badge { border: 1px solid CanvasText; }
  /* Forced colours keep a background's alpha: the floating bar and the tabs need an opaque one. */
  .tc-bar, .tc-tabs, .tc-learn { background: Canvas; }
  .tc-chip[aria-pressed="true"], .tc-tab[aria-selected="true"] { outline: 3px solid Highlight; }
  .tc-tile[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: 2px; }
  .tc-tile[aria-pressed="true"] .tc-heart .tc-icon { fill: Highlight; stroke: Highlight; }
  .tc-heart .tc-icon { stroke: CanvasText; }
  /* Forced colours would paint the dots in the page colour: they keep system colours of their own. */
  .tc-dots li { forced-color-adjust: none; background: GrayText; }
  .tc-dots li.is-current { background: Highlight; box-shadow: none; }
  .tc-grid-step::after { display: none; }
}
