/* Luma interaction layer: consistent feedback, focus, loading and dialogs. */
:root {
  --ux-ease: cubic-bezier(.22, .8, .24, 1);
  --ux-ring: color-mix(in srgb, var(--accent) 42%, transparent);
}

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid var(--ux-ring);
  outline-offset: 2px;
}

:where(button, [role="button"]):not(:disabled) { touch-action: manipulation; }
:where(button, [role="button"]):not(:disabled):active { transform: scale(.985); }
:where(button, input, textarea, select):disabled { cursor: not-allowed; opacity: .5; }
button[aria-busy="true"] { cursor: wait; }

.home-main,
.app-shell.home-module-view :is(.learning-page-inner, .projects-page-inner, .inbox-page-inner) {
  animation: ux-view-enter 220ms var(--ux-ease) both;
}

@keyframes ux-view-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Clear loading state instead of briefly showing an incorrect empty state. */
:is(.learning-page, .projects-page, .inbox-page)[data-loading="true"] :is(.learning-empty, .projects-empty, .inbox-empty) { display: none; }
:is(.learning-page, .projects-page, .inbox-page)[data-loading="true"] :is(.learning-grid, .projects-grid, .inbox-grid):empty::before {
  display: block;
  min-height: 220px;
  grid-column: 1 / -1;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background:
    linear-gradient(100deg, transparent 24%, color-mix(in srgb, var(--surface) 72%, transparent) 42%, transparent 60%) 0 0 / 220% 100%,
    linear-gradient(var(--surface-soft), var(--surface-soft)) 24px 25px / 36% 16px no-repeat,
    linear-gradient(var(--surface-soft), var(--surface-soft)) 24px 59px / calc(100% - 48px) 10px no-repeat,
    linear-gradient(var(--surface-soft), var(--surface-soft)) 24px 83px / 72% 10px no-repeat,
    var(--surface);
  content: "";
  animation: ux-skeleton 1.25s ease-in-out infinite;
}

@keyframes ux-skeleton { to { background-position: -220% 0, 24px 25px, 24px 59px, 24px 83px, 0 0; } }

/* Toasts use one visual language across editor, learning, projects and inbox. */
.toast {
  display: flex;
  min-height: 44px;
  max-width: min(440px, calc(100vw - 32px));
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 11px;
  border: 1px solid color-mix(in srgb, var(--surface) 16%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--text) 95%, transparent);
  color: var(--surface);
  box-shadow: 0 14px 36px rgba(12, 18, 24, .2);
  font-size: 12px;
  line-height: 1.45;
}
.toast::before {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 15%, transparent);
  content: "";
}
.toast:not(.show)::before { display: none; }
.toast[data-tone="error"] { background: color-mix(in srgb, var(--danger) 88%, #1d2329); color: #fff; }

.network-status {
  position: fixed;
  z-index: 155;
  right: 18px;
  bottom: 18px;
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, #b7791f 28%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, #fff5d8 86%, var(--surface));
  color: color-mix(in srgb, #7a4b08 88%, var(--text));
  box-shadow: 0 10px 28px rgba(40, 31, 17, .12);
  font-size: 11px;
}
.network-status[hidden] { display: none; }
.network-status i { width: 7px; height: 7px; border-radius: 50%; background: #c98218; box-shadow: 0 0 0 4px rgba(201, 130, 24, .13); }

/* Product-native confirmation replaces browser confirm boxes. */
.ux-confirm-dialog,
.shortcut-dialog {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 26px 80px rgba(12, 18, 24, .28);
}
.ux-confirm-dialog { width: min(420px, calc(100vw - 28px)); }
.ux-confirm-dialog::backdrop,
.shortcut-dialog::backdrop { background: rgba(12, 15, 20, .52); backdrop-filter: blur(3px); }
.ux-confirm-dialog[open],
.shortcut-dialog[open] { animation: ux-dialog-enter 190ms var(--ux-ease) both; }
@keyframes ux-dialog-enter { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.ux-confirm-dialog form { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 13px; padding: 22px; }
.ux-confirm-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--danger-bg); color: var(--danger); }
.ux-confirm-icon svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ux-confirm-dialog h2 { margin: 1px 0 6px; font-size: 17px; letter-spacing: -.02em; }
.ux-confirm-dialog p { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.65; }
.ux-confirm-dialog footer { display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ux-confirm-dialog button { min-width: 76px; min-height: 40px; padding: 0 14px; cursor: pointer; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-secondary); font-size: 12px; font-weight: 620; }
.ux-confirm-dialog button:hover { background: var(--surface-hover); color: var(--text); }
.ux-confirm-dialog button.destructive { border-color: var(--danger); background: var(--danger); color: #fff; }
.ux-confirm-dialog button.destructive:hover { filter: brightness(.92); }

/* Shortcut guide keeps advanced actions discoverable without crowding the toolbar. */
.shortcut-dialog { width: min(640px, calc(100vw - 28px)); max-height: min(760px, calc(100dvh - 28px)); }
.shortcut-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 17px; border-bottom: 1px solid var(--border-soft); }
.shortcut-head span { color: var(--accent); font-size: 9px; font-weight: 720; letter-spacing: .14em; }
.shortcut-head h2 { margin: 5px 0 3px; font-size: 22px; letter-spacing: -.03em; }
.shortcut-head p { margin: 0; color: var(--text-tertiary); font-size: 11px; }
.shortcut-head button { display: grid; width: 44px; height: 44px; padding: 0; cursor: pointer; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--text-tertiary); font-size: 22px; }
.shortcut-head button:hover { background: var(--surface-hover); color: var(--text); }
.shortcut-body { display: grid; max-height: calc(100dvh - 210px); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; overflow-y: auto; padding: 20px 24px 24px; }
.shortcut-body h3 { margin: 0 0 9px; color: var(--text-tertiary); font-size: 10px; font-weight: 680; letter-spacing: .08em; text-transform: uppercase; }
.shortcut-row { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-secondary); font-size: 11px; }
.shortcut-row:last-child { border-bottom: 0; }
.shortcut-keys { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.shortcut-dialog kbd { min-width: 25px; height: 25px; padding: 0 7px; border: 1px solid var(--border); border-bottom-color: color-mix(in srgb, var(--text) 24%, var(--border)); border-radius: 6px; background: var(--surface-soft); color: var(--text); font: 10px/23px var(--font-ui); text-align: center; box-shadow: 0 1px 0 var(--border); }
.shortcut-dialog > footer { display: flex; min-height: 52px; align-items: center; justify-content: center; gap: 7px; padding: 8px 18px; border-top: 1px solid var(--border-soft); color: var(--text-tertiary); font-size: 10px; }

@media (max-width: 620px) {
  :where(button, [role="button"]):not(:disabled):active { transform: scale(.98); }
  .network-status { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; justify-content: center; }
  .toast { bottom: max(14px, env(safe-area-inset-bottom)); }
  .shortcut-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .shortcut-body { grid-template-columns: 1fr; gap: 22px; }
  .ux-confirm-dialog form { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .home-main,
  .app-shell.home-module-view :is(.learning-page-inner, .projects-page-inner, .inbox-page-inner),
  .ux-confirm-dialog[open],
  .shortcut-dialog[open] { animation: none; }
  :is(.learning-page, .projects-page, .inbox-page)[data-loading="true"] :is(.learning-grid, .projects-grid, .inbox-grid):empty::before { animation: none; }
  :where(button, [role="button"]):not(:disabled):active { transform: none; }
}
