/* Wortklar design system — progressive layer over the existing application. */
:root {
  color-scheme: light;
  --wk-navy-950: #071a3d;
  --wk-blue-600: #087ef5;
  --wk-blue-700: #0568d0;
  --wk-neutral-25: #f7f9fc;
  --wk-neutral-0: #ffffff;
  --wk-slate-500: #66738c;
  --wk-slate-200: #e5ebf3;
  --wk-space-1: 0.25rem;
  --wk-space-2: 0.5rem;
  --wk-space-3: 0.75rem;
  --wk-space-4: 1rem;
  --wk-space-6: 1.5rem;
  --wk-space-8: 2rem;
  --wk-space-12: 3rem;
  --wk-radius-sm: 0.625rem;
  --wk-radius-md: 0.875rem;
  --wk-radius-lg: 1.125rem;
  --wk-radius-xl: 1.5rem;
  --wk-radius-card: 1.375rem;
  --wk-radius-modal: 1.75rem;
  --wk-shadow-xs: 0 1px 2px rgb(7 26 61 / 0.05);
  --wk-shadow-sm: 0 5px 18px rgb(7 26 61 / 0.07);
  --wk-shadow-card: 0 14px 34px rgb(7 26 61 / 0.09), inset 0 1px 0 rgb(255 255 255 / 0.75);
  --wk-shadow-floating: 0 22px 52px rgb(7 26 61 / 0.15);
  --wk-blur-surface: 18px;
  --wk-duration-fast: 150ms;
  --wk-duration-normal: 260ms;
  --wk-duration-slow: 400ms;
  --wk-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --wk-ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1.08);
  --wk-touch-target: 44px;
  --wk-icon-sm: 1rem;
  --wk-icon-md: 1.25rem;
  --wk-icon-lg: 1.5rem;
  --wk-z-header: 20;
  --wk-z-modal: 100;

  --wk-bg: var(--wk-neutral-25);
  --wk-surface: var(--wk-neutral-0);
  --wk-surface-raised: rgb(255 255 255 / 0.84);
  --wk-text: var(--wk-navy-950);
  --wk-text-muted: var(--wk-slate-500);
  --wk-border: var(--wk-slate-200);
  --wk-primary: var(--wk-blue-600);
  --wk-focus: #087ef5;
  --wk-overlay: rgb(7 26 61 / 0.55);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --wk-bg: #071225;
  --wk-surface: #0e203c;
  --wk-surface-raised: rgb(18 42 75 / 0.88);
  --wk-text: #f4f7fb;
  --wk-text-muted: #aab8ce;
  --wk-border: #263c5e;
  --wk-primary: #58a8ff;
  --wk-focus: #7dbbff;
  --wk-shadow-card: 0 14px 34px rgb(0 0 0 / 0.22), inset 0 1px 0 rgb(255 255 255 / 0.06);
  --wk-shadow-floating: 0 22px 52px rgb(0 0 0 / 0.32);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --wk-bg: #071225;
    --wk-surface: #0e203c;
    --wk-surface-raised: rgb(18 42 75 / 0.88);
    --wk-text: #f4f7fb;
    --wk-text-muted: #aab8ce;
    --wk-border: #263c5e;
    --wk-primary: #58a8ff;
    --wk-focus: #7dbbff;
    --wk-shadow-card: 0 14px 34px rgb(0 0 0 / 0.22), inset 0 1px 0 rgb(255 255 255 / 0.06);
  }
}

body {
  background: var(--wk-bg);
  color: var(--wk-text);
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--wk-focus) 65%, white);
  outline-offset: 3px;
}

/* Home owns its shell: the learning views retain the existing navigation. */
body[data-current-view="home"] .sidebar,
body[data-current-view="home"] .app-header,
body[data-current-view="home"] .bottom-nav {
  display: none;
}

body[data-current-view="home"] .app-shell {
  display: block;
  background:
    radial-gradient(circle at 88% 4%, rgb(8 126 245 / 0.10), transparent 27rem),
    radial-gradient(circle at 6% 35%, rgb(127 99 246 / 0.07), transparent 24rem),
    var(--wk-bg);
}

body[data-current-view="home"] .main-column,
body[data-current-view="home"] .main-content {
  width: 100%;
  max-width: none;
  padding: 0;
  margin: 0;
}

.home-view {
  min-height: 100dvh;
  padding: max(var(--wk-space-4), env(safe-area-inset-top)) var(--wk-space-4)
    max(calc(var(--wk-space-8) + env(safe-area-inset-bottom)), var(--wk-space-8));
}

.home-shell {
  width: min(100%, 1120px);
  margin-inline: auto;
}

.home-topbar,
.home-context,
.home-actions,
.home-dashboard-cta,
.home-module {
  display: flex;
  align-items: center;
}

.home-topbar {
  justify-content: space-between;
  min-height: 54px;
}

.home-brand {
  border: 0;
  background: none;
  color: var(--wk-text);
  padding: 0;
  min-height: var(--wk-touch-target);
}

.home-brand .brand-symbol {
  box-shadow: var(--wk-shadow-sm);
}

.home-brand .brand-text {
  display: grid;
  text-align: left;
  line-height: 1.05;
}

.home-brand strong {
  font-size: clamp(1.35rem, 4.4vw, 1.8rem);
  letter-spacing: -0.035em;
}

.home-brand small {
  margin-top: 0.28rem;
  color: var(--wk-text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.home-actions { gap: var(--wk-space-2); }

.home-action,
.home-avatar {
  width: var(--wk-touch-target);
  height: var(--wk-touch-target);
  min-width: var(--wk-touch-target);
  border: 1px solid var(--wk-border);
  background: var(--wk-surface-raised);
  color: var(--wk-text);
  box-shadow: var(--wk-shadow-xs);
  backdrop-filter: blur(var(--wk-blur-surface));
}

.home-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--wk-navy-950);
  color: white;
  font-weight: 800;
}

.home-context {
  justify-content: space-between;
  gap: var(--wk-space-3);
  margin-block: var(--wk-space-6) var(--wk-space-4);
}

.home-clock { min-width: 0; }
.home-clock p { margin: 0 0 0.2rem; color: var(--wk-text-muted); font-size: 0.76rem; font-weight: 650; }
.home-clock time { display: block; font-size: clamp(2.15rem, 11vw, 4.25rem); line-height: 0.95; letter-spacing: -0.065em; font-weight: 820; }
.home-clock > span { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.45rem; color: var(--wk-text-muted); font-size: 0.8rem; }
.home-clock .icon { width: 0.9rem; height: 0.9rem; }

.home-weather {
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.2rem 0.55rem;
  min-width: 142px;
  padding: 0.8rem 2rem 0.75rem 0.8rem;
  border: 1px solid rgb(255 255 255 / 0.34);
  border-radius: var(--wk-radius-lg);
  background: linear-gradient(145deg, rgb(7 26 61 / 0.92), rgb(26 67 118 / 0.84));
  color: white;
  box-shadow: var(--wk-shadow-card);
  backdrop-filter: blur(var(--wk-blur-surface));
}

.home-weather-icon { grid-row: 1 / 3; align-self: center; font-size: 1.45rem; }
.home-weather div:nth-child(2) { display: grid; }
.home-weather strong { font-size: 1.25rem; line-height: 1; }
.home-weather span { max-width: 82px; margin-top: 0.2rem; font-size: 0.63rem; line-height: 1.15; opacity: 0.85; }
.home-weather small { grid-column: 1 / 3; font-size: 0.62rem; opacity: 0.72; }
.home-weather button { position: absolute; right: 0.35rem; bottom: 0.35rem; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.12); color: white; }
.home-weather button .icon { width: 0.85rem; height: 0.85rem; }
.home-weather[aria-busy="true"] { overflow: hidden; }
.home-weather[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgb(255 255 255 / 0.15) 45%, transparent 70%); animation: wk-shimmer 1.3s infinite; }

.home-hero {
  position: relative;
  isolation: isolate;
  min-height: 186px;
  display: flex;
  align-items: center;
  overflow: hidden;
  margin-bottom: var(--wk-space-4);
  padding: 1.35rem 42% 1.35rem 1.25rem;
  border: 1px solid color-mix(in srgb, var(--wk-border) 70%, white);
  border-radius: var(--wk-radius-modal);
  background:
    radial-gradient(circle at 82% 20%, rgb(8 126 245 / 0.24), transparent 42%),
    linear-gradient(135deg, #fdfefe, #eef4ff 70%, #f1ecff);
  box-shadow: var(--wk-shadow-card);
}

.home-hero::before { content: ""; position: absolute; width: 160px; height: 160px; border: 24px solid rgb(8 126 245 / 0.07); border-radius: 50%; right: 12%; top: -42%; z-index: -1; }
.home-hero-copy { position: relative; z-index: 2; }
.home-hero .overline { margin: 0 0 0.45rem; color: var(--wk-primary); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.home-hero h1 { margin: 0; max-width: 14ch; color: var(--wk-navy-950); font-size: clamp(1.55rem, 6.9vw, 3.25rem); line-height: 1.03; letter-spacing: -0.052em; }
.home-hero-copy > p:last-child { margin: 0.7rem 0 0; color: #596a86; font-size: clamp(0.78rem, 2.8vw, 1rem); line-height: 1.4; }
.home-hero-person { position: absolute; z-index: 1; right: -3%; bottom: -12%; width: min(49%, 380px); height: auto; pointer-events: none; filter: drop-shadow(0 18px 20px rgb(7 26 61 / 0.14)); }

.home-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.home-module {
  --module-accent: #ec6f87;
  --module-tint: #fff0f3;
  position: relative;
  min-width: 0;
  min-height: 108px;
  gap: 0.65rem;
  padding: 0.78rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--module-accent) 13%, var(--wk-border));
  border-radius: var(--wk-radius-card);
  background: linear-gradient(140deg, var(--wk-surface) 4%, var(--module-tint));
  color: var(--wk-text);
  text-align: left;
  box-shadow: var(--wk-shadow-sm);
  transition: transform var(--wk-duration-fast) var(--wk-ease-standard), box-shadow var(--wk-duration-fast) var(--wk-ease-standard), border-color var(--wk-duration-fast) var(--wk-ease-standard);
}

.home-module > span:nth-child(2) { min-width: 0; flex: 1; }
.home-module strong { display: block; overflow-wrap: anywhere; font-size: clamp(0.83rem, 3.4vw, 1rem); line-height: 1.12; letter-spacing: -0.022em; }
.home-module small { display: block; margin-top: 0.35rem; color: var(--wk-text-muted); font-size: clamp(0.66rem, 2.8vw, 0.78rem); line-height: 1.32; }
.home-module-icon { display: grid; flex: 0 0 auto; place-items: center; width: 2.65rem; height: 2.65rem; border-radius: 0.95rem; background: color-mix(in srgb, var(--module-accent) 15%, white); color: var(--module-accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8), 0 6px 12px color-mix(in srgb, var(--module-accent) 17%, transparent); transform: rotate(-3deg); }
.home-module-icon .icon { width: 1.45rem; height: 1.45rem; }
.home-module-arrow { flex: 0 0 auto; width: 0.9rem; height: 0.9rem; color: var(--module-accent); }
.home-module--verbs { --module-accent: #ca43c7; --module-tint: #fff0fe; }
.home-module--shadow { --module-accent: #ef7a39; --module-tint: #fff5ee; }
.home-module--listen { --module-accent: #5968ee; --module-tint: #f1f2ff; }
.home-module--interview { --module-accent: #8059e8; --module-tint: #f4f0ff; }
.home-module--agentur { --module-accent: #e9509b; --module-tint: #fff0f7; }
.home-module--writing { --module-accent: #168ee5; --module-tint: #eef8ff; }
.home-module--test { --module-accent: #159bd1; --module-tint: #edfbff; }
.home-module--errors { --module-accent: #21a9a0; --module-tint: #ecfbf9; }
.home-module--library { --module-accent: #d68a16; --module-tint: #fff8e8; }
.home-module--settings { --module-accent: #687a96; --module-tint: #f2f5f9; }
.home-module:active, .home-dashboard-cta:active { transform: scale(0.98); box-shadow: var(--wk-shadow-xs); }

.home-dashboard-cta {
  width: 100%;
  min-height: 76px;
  gap: var(--wk-space-3);
  margin-top: var(--wk-space-4);
  padding: 0.85rem 1rem;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: var(--wk-radius-card);
  background: linear-gradient(110deg, #087ef5, #3155e9 58%, #792de9);
  color: white;
  text-align: left;
  box-shadow: 0 16px 32px rgb(38 91 222 / 0.25);
  transition: transform var(--wk-duration-fast) var(--wk-ease-standard), box-shadow var(--wk-duration-fast) var(--wk-ease-standard);
}
.home-dashboard-icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 1rem; background: rgb(255 255 255 / 0.14); }
.home-dashboard-cta > span:nth-child(2) { display: grid; flex: 1; }
.home-dashboard-cta strong { font-size: 1rem; }
.home-dashboard-cta small { margin-top: 0.2rem; color: rgb(255 255 255 / 0.76); font-size: 0.72rem; }
.home-weather-credit { margin: 0.8rem 0 0; color: var(--wk-text-muted); text-align: center; font-size: 0.62rem; }

.home-enter { animation: wk-enter var(--wk-duration-slow) var(--wk-ease-standard) both; }
.home-enter--2 { animation-delay: 45ms; }
.home-enter--3 { animation-delay: 90ms; }
.home-enter--4 { animation-delay: 120ms; }
.home-module { animation: wk-enter 330ms var(--wk-ease-standard) both; }
.home-module:nth-child(2) { animation-delay: 30ms; } .home-module:nth-child(3) { animation-delay: 60ms; }
.home-module:nth-child(4) { animation-delay: 90ms; } .home-module:nth-child(5) { animation-delay: 120ms; }
.home-module:nth-child(6) { animation-delay: 150ms; } .home-module:nth-child(7) { animation-delay: 180ms; }
.home-module:nth-child(8) { animation-delay: 210ms; } .home-module:nth-child(9) { animation-delay: 240ms; }
.home-module:nth-child(10) { animation-delay: 270ms; } .home-module:nth-child(11) { animation-delay: 300ms; }

/* Login presentation, with the existing form and API unchanged. */
.porte {
  background:
    radial-gradient(circle at 80% 12%, rgb(8 126 245 / 0.15), transparent 34rem),
    radial-gradient(circle at 8% 88%, rgb(127 99 246 / 0.10), transparent 30rem),
    var(--wk-bg);
}
.porte-carte { position: relative; overflow: hidden; border: 1px solid var(--wk-border); border-radius: var(--wk-radius-modal); background: var(--wk-surface-raised); box-shadow: var(--wk-shadow-floating); backdrop-filter: blur(var(--wk-blur-surface)); }
.porte-illustration { position: relative; width: 100%; min-height: 156px; margin-bottom: 0.9rem; overflow: hidden; border-radius: var(--wk-radius-xl); background: radial-gradient(circle at 82% 40%, #d9e9ff, transparent 38%), linear-gradient(135deg, #edf5ff, #f7f2ff); animation: wk-enter var(--wk-duration-slow) var(--wk-ease-standard) both; }
.porte-illustration img { position: absolute; right: -4%; bottom: -42%; width: 72%; height: auto; filter: drop-shadow(0 12px 18px rgb(7 26 61 / 0.14)); }
.porte-logo, .porte-carte form { animation: wk-enter var(--wk-duration-slow) var(--wk-ease-standard) both; }
.porte-carte form { animation-delay: 90ms; }

/* Existing dashboard and application surfaces inherit the calmer material. */
.dashboard :where(.panel, .quick-card, .today-card, .progress-card),
.view :where(.card, .panel) { border-color: var(--wk-border); border-radius: var(--wk-radius-card); }

@media (hover: hover) and (pointer: fine) {
  .home-module:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--module-accent) 28%, var(--wk-border)); box-shadow: var(--wk-shadow-card); }
  .home-dashboard-cta:hover { transform: translateY(-2px); box-shadow: 0 20px 38px rgb(38 91 222 / 0.31); }
}

@media (min-width: 720px) {
  .home-view { padding-inline: var(--wk-space-8); }
  .home-context { margin-top: var(--wk-space-8); }
  .home-module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--wk-space-3); }
  .home-module { min-height: 122px; padding: 1rem; }
  .home-hero { min-height: 250px; padding-left: var(--wk-space-8); }
  .home-hero-person { right: 6%; bottom: -10%; width: min(34%, 310px); }
}

@media (min-width: 1060px) {
  .home-module-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .home-module:nth-child(9), .home-module:nth-child(10), .home-module:nth-child(11) { grid-column: auto; }
  .home-dashboard-cta { width: min(100%, 720px); margin-inline: auto; margin-top: var(--wk-space-6); }
}

@media (max-width: 349px) {
  .home-view { padding-inline: 0.72rem; }
  .home-context { align-items: stretch; }
  .home-weather { min-width: 128px; padding-left: 0.62rem; }
  .home-hero { min-height: 170px; padding-left: 1rem; }
  .home-module { gap: 0.45rem; min-height: 103px; padding-inline: 0.56rem; }
  .home-module-icon { width: 2.25rem; height: 2.25rem; }
  .home-module-icon .icon { width: 1.2rem; height: 1.2rem; }
  .home-module-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .home-enter, .home-module, .porte-logo, .porte-illustration, .porte-carte form { animation: none !important; }
  .home-module, .home-dashboard-cta { transition: none; }
  .home-weather[aria-busy="true"]::after { animation: none; }
}

:root[data-motion="reduced"] .home-enter,
:root[data-motion="reduced"] .home-module,
:root[data-motion="reduced"] .porte-logo,
:root[data-motion="reduced"] .porte-illustration,
:root[data-motion="reduced"] .porte-carte form { animation: none !important; }

:root[data-theme="dark"] .home-module {
  background: linear-gradient(140deg, var(--wk-surface) 25%, color-mix(in srgb, var(--wk-surface) 86%, var(--module-accent)));
}
:root[data-theme="dark"] .home-module-icon { background: color-mix(in srgb, var(--wk-surface) 70%, var(--module-accent)); }
:root[data-theme="dark"] .home-hero { border-color: var(--wk-border); background: radial-gradient(circle at 82% 20%, rgb(88 168 255 / 0.18), transparent 42%), linear-gradient(135deg, #10284a, #111f3b 70%, #201b45); }
:root[data-theme="dark"] .home-hero h1 { color: var(--wk-text); }
:root[data-theme="dark"] .home-hero-copy > p:last-child { color: var(--wk-text-muted); }

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .home-module { background: linear-gradient(140deg, var(--wk-surface) 25%, color-mix(in srgb, var(--wk-surface) 86%, var(--module-accent))); }
  :root[data-theme="system"] .home-module-icon { background: color-mix(in srgb, var(--wk-surface) 70%, var(--module-accent)); }
  :root[data-theme="system"] .home-hero { border-color: var(--wk-border); background: radial-gradient(circle at 82% 20%, rgb(88 168 255 / 0.18), transparent 42%), linear-gradient(135deg, #10284a, #111f3b 70%, #201b45); }
  :root[data-theme="system"] .home-hero h1 { color: var(--wk-text); }
  :root[data-theme="system"] .home-hero-copy > p:last-child { color: var(--wk-text-muted); }
}

@keyframes wk-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes wk-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
