/*
 * Application-wide base styles. Design tokens live in tokens.css; every file in
 * this directory is bundled by `stylesheet_link_tag :app`.
 */

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--type-body);
  line-height: 1.5;
  /* Numbers line up in columns everywhere in this app. */
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--accent);
}

/* Pixel width, so enlarged text wraps inside the phone canvas instead of
   widening it. Each edge clears its own safe-area inset. */
.page {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(40px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
}

@media (max-width: 360px) {
  .page {
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
  }
}

/* Shared buttons: auth, alerts, the builder, unsubscribe and the cap sheet. */
.btn {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--ghost {
  border: 1px solid var(--control-edge);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
}

.btn--quiet {
  min-height: 44px;
  padding: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
}

/* A quiet link without .btn stays content-sized; inline boxes ignore min-height. */
.btn--quiet:not(.btn) {
  display: inline-flex;
  align-items: center;
}

.btn--danger {
  border: 1px solid var(--grade-c);
  background: transparent;
  color: var(--grade-c);
}

.btns {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.btns--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 360px) {
  .btns--2 {
    grid-template-columns: 1fr;
  }
}

/* Hover brightens every enabled button, not only .btn. */
@media (hover: hover) {
  :is(button, .btn):not(:disabled):hover {
    filter: brightness(1.08);
  }

  :is(.btn--ghost, .btn--quiet, .chip, .sortbar__button):not(:disabled):hover {
    background: var(--raised);
  }
}

.btn:not(:disabled):active {
  filter: brightness(.93);
  transform: translateY(1px);
}

/* :is() takes its most specific argument, so this outranks the field and title
   input resets in later files without relying on load order. */
:is(button, a[href], input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--focus-gap);
  scroll-margin-block: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .btn:not(:disabled):active {
    transform: none;
  }
}

@media (forced-colors: active) {
  /* On body, because tokens.css loads later and would win a :root tie. Aliases
     resolve where they're declared, so they're restated too. */
  body {
    --ink: CanvasText;
    --ink-soft: CanvasText;
    --muted: CanvasText;
    --accent: LinkText;
    --accent-bright: LinkText;
    --text-secondary: CanvasText;
    --text-caption: CanvasText;
    --text-placeholder: CanvasText;
    --control-edge: ButtonText;
    --focus-ring: Highlight;
    --focus-gap: Canvas;
  }

  :where(button, input, summary) {
    border: 1px solid ButtonText;
  }

  .btn:disabled {
    color: GrayText;
  }
}

/* Brand wordmark (app/views/shared/_brand.html.erb). */
.brand {
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.brand__trail {
  color: var(--accent);
}

/* Masthead and the links around it. The account slot's hidden and reserved
   rules stay in list.css beside the home list that fills them. */
.masthead__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.masthead__brand {
  text-decoration: none;
}

.locale-toggle,
.masthead__account-link,
.back,
.alert-item__edit,
.list-footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--ink-soft);
  font-size: .75rem;
  text-decoration: none;
}

.back {
  margin-top: 12px;
}

.resort__back {
  margin: 14px 0 0;
  font-size: .75rem;
}

/* Short status lines under the masthead. */
.banner {
  margin: 14px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-notice);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .75rem;
}

.banner--offline {
  border: 1px solid var(--grade-b);
  color: var(--grade-b);
}

.banner[hidden] {
  display: none;
}

/* A framed message: a strong lead line, supporting paragraphs, an optional
   action. Paused alerts use the neutral base, never the warning. */
.notice {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--control-edge);
  border-radius: var(--radius-notice);
  background: var(--surface);
  font-size: .8125rem;
}

/* A heading as the lead line, at the notice's size like the strong line. It can
   hold a resort name, so a long one breaks to fit. */
.notice__title {
  margin: 0;
  color: var(--ink);
  font-size: inherit;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.notice p {
  margin: 6px 0 12px;
  color: var(--ink-soft);
}

/* A message with no lead line sits evenly inside the padding. */
.notice > p:only-child {
  margin: 0;
}

.notice .btn {
  margin-top: 12px;
}

.notice--warning {
  border-color: var(--grade-b);
}

.notice--warning strong {
  color: var(--grade-b);
}

.notice--error {
  border-color: var(--grade-c);
}

.notice--error strong {
  color: var(--grade-c);
}

/* A page that is only a title, a line and a way on. */
.utility {
  margin-top: 32px;
}

.utility__title {
  margin: 0;
  font-size: var(--type-page);
  font-weight: 700;
  line-height: 1.3;
}

.utility__body {
  color: var(--ink-soft);
  font-size: .8125rem;
  line-height: 1.5;
}

.utility .btn {
  margin-top: 24px;
}

.utility .checkout-return__actions {
  margin-top: 24px;
}

.utility .checkout-return__actions .btn {
  margin-top: 0;
}

/* The removal confirmation, one look from the list bell and the edit screen. */
.confirm-dialog {
  width: calc(100% - 40px);
  max-width: 340px;
  /* Short viewports scroll the dialog, so both answers stay reachable. */
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px;
  border: 1px solid var(--muted);
  border-radius: var(--radius-panel);
  background: var(--raised);
  color: var(--ink);
  /* Saved names and conditions show in full. Anywhere only reaches strings
     with no other break. */
  overflow-wrap: anywhere;
}

/* The cap sheet's scrim. A literal, because older browsers give ::backdrop
   no custom properties. */
.confirm-dialog::backdrop {
  background: rgba(13, 20, 31, 0.72);
}

.confirm-dialog__title {
  margin: 0 0 12px;
  font-size: var(--type-section);
  font-weight: 700;
  line-height: 1.35;
}

.confirm-dialog__context,
.confirm-dialog__description {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: .8125rem;
  line-height: 1.5;
}

.confirm-dialog .btns {
  margin-top: 16px;
}

.home__heading {
  margin: 28px 0 10px;
  font-size: 22px;
  line-height: 1.3;
}

.home__body {
  margin: 0 0 20px;
  color: var(--ink-soft);
}

.home__status {
  color: var(--muted);
  font-size: 12.5px;
}
