/* Mobile Card view for Today. Only phones and tablets with touch get it; everything else keeps the full page. */
/* Nunito (SIL Open Font License, see fonts/OFL-Nunito.txt): rounded and easy to read at a glance on small screens. Self-hosted, so no third-party font requests. */
@font-face {
  font-family: 'Nunito';
  src: url('fonts/nunito-latin-wght.woff2') format('woff2');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}
#today-cards { display: none; }

@media (max-width: 768px) and (pointer: coarse) {
  body.today-cards-on { overflow: hidden; }
  body.today-cards-on .workspace-bar,
  body.today-cards-on #earned-hours-lens,
  body.today-cards-on #dashboard-view.active > :not(#today-cards) { display: none !important; }

  body.today-cards-on #today-cards {
    display: block;
    position: fixed;
    top: 60px;
    left: 0;
    width: 100vw;
    width: 100dvw;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    z-index: 40;
    background: var(--bg, #e9eef4);
    color: var(--text-primary, #152b3d);
    font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
  }

  #today-cards .tc-bar {
    position: fixed;
    top: 8px;
    left: 64px;
    right: 12px;
    height: 44px;
    z-index: 41;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  #today-cards .tc-nav {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(21, 43, 61, .15);
    background: #fff;
    color: var(--text-primary, #152b3d);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }
  #today-cards .tc-nav:disabled { opacity: .35; cursor: default; }
  #today-cards .tc-dots {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    overflow: hidden;
  }
  #today-cards .tc-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(21, 43, 61, .2);
    transition: transform .2s ease, background .2s ease;
  }
  #today-cards .tc-dot.tone-danger { background: rgba(190, 40, 60, .35); }
  #today-cards .tc-dot.tone-warning { background: rgba(190, 120, 20, .35); }
  #today-cards .tc-dot.is-active { background: var(--ink-forest, #12392f); transform: scale(1.35); }

  #today-cards .tc-track {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #today-cards .tc-track::-webkit-scrollbar { display: none; }
  #today-cards .tc-track:focus-visible { outline: 3px solid var(--primary, #087259); outline-offset: -3px; }

  #today-cards .tc-card {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow-y: auto;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    display: flex;
  }
  #today-cards .tc-inner {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: 28px 22px;
    border-radius: 28px;
    --tc-a: #e8f2fa;
    --tc-b: #d4e6fb;
    --tc-blob: rgba(91, 124, 250, .18);
    background: linear-gradient(160deg, var(--tc-a) 0%, var(--tc-b) 100%);
    box-shadow: 0 14px 34px rgba(21, 43, 61, .12);
    min-height: 0;
    overflow-wrap: anywhere;
  }
  /* Two soft blobs give each card some personality without competing with the number. */
  #today-cards .tc-inner::before,
  #today-cards .tc-inner::after {
    content: '';
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    background: var(--tc-blob);
    pointer-events: none;
  }
  #today-cards .tc-inner::before { width: 240px; height: 240px; top: -90px; right: -80px; }
  #today-cards .tc-inner::after { width: 160px; height: 160px; bottom: -60px; left: -50px; opacity: .7; }
  #today-cards .tone-danger .tc-inner { --tc-a: #fdecef; --tc-b: #f9d3db; --tc-blob: rgba(229, 72, 107, .18); }
  #today-cards .tone-warning .tc-inner { --tc-a: #fdf1e3; --tc-b: #f9dcbc; --tc-blob: rgba(245, 158, 11, .2); }
  #today-cards .tone-success .tc-inner,
  #today-cards [data-tc-key="workday"].tone-info .tc-inner,
  #today-cards [data-tc-key="paycheck"].tone-info .tc-inner { --tc-a: #e9f7f0; --tc-b: #c9ecdb; --tc-blob: rgba(16, 185, 129, .18); }
  #today-cards [data-tc-key^="rate:"] .tc-inner,
  #today-cards [data-tc-key="take-back"] .tc-inner { --tc-a: #f1ecfb; --tc-b: #ddd1f6; --tc-blob: rgba(139, 92, 246, .18); }
  #today-cards [data-tc-key="price"] .tc-inner { --tc-a: #fbf5e3; --tc-b: #f3e3b3; --tc-blob: rgba(234, 179, 8, .2); }

  #today-cards .tc-head { display: flex; align-items: center; gap: 12px; }
  #today-cards .tc-icon {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(255, 255, 255, .75);
    box-shadow: 0 6px 16px rgba(21, 43, 61, .1);
    font-size: 30px;
    line-height: 1;
  }

  #today-cards .tc-visual { margin: 2px 0 0; }
  #today-cards .tc-caption { margin: 8px 0 0; font-size: 16px; font-weight: 600; color: var(--text-secondary, #4a6074); }
  #today-cards .tc-grow { display: block; height: 100%; width: var(--w); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
  #today-cards .tc-card:not(.is-active) .tc-grow { width: 0; }

  #today-cards .tc-day-bar,
  #today-cards .tc-over-bar {
    position: relative;
    display: flex;
    height: 26px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, .7);
    box-shadow: inset 0 1px 3px rgba(21, 43, 61, .12);
  }
  #today-cards .tc-day-ticks { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12px; color: var(--text-secondary, #4a6074); }
  #today-cards .tc-day-ticks span { width: 0; display: flex; justify-content: center; white-space: nowrap; }
  #today-cards .tc-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 16px; }
  #today-cards .tc-legend li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .7); }
  #today-cards .tc-legend i { width: 12px; height: 12px; border-radius: 4px; }

  #today-cards .tc-battery { position: relative; padding-right: 14px; }
  #today-cards .tc-battery-body {
    height: 52px;
    border: 4px solid var(--ink-forest, #12392f);
    border-radius: 14px;
    padding: 4px;
    background: rgba(255, 255, 255, .7);
  }
  #today-cards .tc-battery-body .tc-grow { border-radius: 8px; background: linear-gradient(90deg, #10b981, #34d399); }
  #today-cards .tc-battery.level-mid .tc-grow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
  #today-cards .tc-battery.level-low .tc-grow { background: linear-gradient(90deg, #e5486b, #fb7185); }
  #today-cards .tc-battery-tip { position: absolute; right: 2px; top: 17px; width: 10px; height: 18px; border-radius: 0 6px 6px 0; background: var(--ink-forest, #12392f); }

  #today-cards .tc-countdown { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  #today-cards .tc-countdown .tc-caption { flex-basis: 100%; margin-top: 4px; }
  #today-cards .tc-tick { width: 14px; height: 14px; border-radius: 50%; background: rgba(21, 43, 61, .18); }
  #today-cards .tc-tick.is-today { background: var(--primary, #087259); box-shadow: 0 0 0 4px rgba(8, 114, 89, .2); }
  #today-cards .tc-pay { font-size: 26px; line-height: 1; }

  #today-cards .tc-calendar {
    align-self: flex-start;
    width: 96px;
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 20px rgba(21, 43, 61, .14);
    text-align: center;
    transform: rotate(-4deg);
  }
  #today-cards .tc-cal-month { display: block; padding: 4px 0; background: var(--primary, #087259); color: #fff; font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
  #today-cards .tc-calendar.is-late .tc-cal-month { background: #c0264a; }
  #today-cards .tc-cal-day { display: block; font-size: 40px; font-weight: 800; line-height: 1.1; color: var(--ink-forest, #12392f); }
  #today-cards .tc-cal-week { display: block; padding-bottom: 6px; font-size: 16px; color: var(--text-secondary, #4a6074); }

  #today-cards .tc-over-ok { background: linear-gradient(90deg, #f59e0b, #f97316); }
  #today-cards .tc-over-hot { background: repeating-linear-gradient(135deg, #e5486b 0 10px, #c0264a 10px 20px); }
  #today-cards .tc-over-line { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; background: var(--ink-forest, #12392f); border-radius: 2px; }

  #today-cards .tc-chip {
    align-self: flex-start;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .75);
    font-size: 16px;
    font-weight: 700;
    color: var(--ink-forest, #12392f);
  }

  /* A little pop when a card arrives. */
  #today-cards .tc-card.is-active .tc-icon { animation: tc-bounce .7s cubic-bezier(.3, 1.6, .5, 1) both; }
  #today-cards .tc-card.is-active .tc-hero { animation: tc-rise .5s ease-out both; }
  @keyframes tc-bounce { 0% { transform: scale(.4) rotate(-15deg); } 100% { transform: none; } }
  @keyframes tc-rise { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: none; } }
  #today-cards .tc-label {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary, #4a6074);
  }
  #today-cards .tc-hero {
    margin: 0;
    font-size: clamp(48px, 14vw, 64px);
    line-height: 1.05;
    font-weight: 900;
    letter-spacing: -.02em;
    color: var(--ink-forest, #12392f);
    font-variant-numeric: tabular-nums;
  }
  #today-cards .tone-danger .tc-hero { color: #9b1c36; }
  #today-cards .tc-unit { font-size: .5em; font-weight: 700; }
  #today-cards .tc-num-text { font-size: .7em; }
  #today-cards .tc-same {
    margin: -6px 0 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary, #4a6074);
  }
  #today-cards .tc-sentence {
    margin: 0;
    font-size: clamp(20px, 5.6vw, 24px);
    line-height: 1.35;
    font-weight: 600;
    color: var(--text-primary, #152b3d);
  }
  #today-cards .tc-status { margin: 0; font-size: 16px; color: var(--text-secondary, #4a6074); }
  #today-cards .tc-status:empty { display: none; }

  #today-cards .tc-rate .tc-btn span { font-size: 22px; margin-right: 6px; }
  #today-cards .tc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
  #today-cards .tc-btn {
    flex: 1 1 auto;
    min-height: 48px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1.5px solid rgba(21, 43, 61, .2);
    background: #fff;
    color: var(--text-primary, #152b3d);
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  #today-cards .tc-btn-primary { flex-basis: 100%; background: var(--primary, #087259); border-color: var(--primary, #087259); color: #fff; }
  #today-cards .tc-btn:disabled { opacity: .55; cursor: default; }

  #today-cards .tc-price { display: flex; flex-direction: column; gap: 6px; font-size: 16px; font-weight: 600; }
  #today-cards .tc-price input {
    min-height: 52px;
    padding: 8px 14px;
    border-radius: 14px;
    border: 1.5px solid rgba(21, 43, 61, .25);
    font-size: 22px;
    background: #fff;
    box-sizing: border-box;
    width: 100%;
  }

  #today-cards .tc-details {
    align-self: flex-start;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary, #087259);
    text-decoration: none;
    cursor: pointer;
  }

  .today-view-toggle { font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif; display: flex; gap: 6px; padding: 8px 12px; }
  .today-view-toggle[hidden] { display: none; }
  .today-view-toggle button {
    flex: 1;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .3);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
  }
  .today-view-toggle button[aria-pressed="true"] { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .6); }
}

@media (prefers-reduced-motion: reduce) {
  #today-cards .tc-track { scroll-behavior: auto; }
  #today-cards .tc-dot, #today-cards .tc-grow { transition: none; }
  #today-cards .tc-card:not(.is-active) .tc-grow { width: var(--w); }
  #today-cards .tc-card.is-active .tc-icon, #today-cards .tc-card.is-active .tc-hero { animation: none; }
}
