/*
 * lagom's account page (index.ftl, js/account.js): what someone comes here for, on one
 * page, phone first. The sign-in pages' tokens, type and icons (login/resources/css/lagom.css),
 * so the two read as one place. Tokens first; every rule below uses them.
 */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f7f5f1;
  --surface: #ffffff;
  --ink: #1b1d1a;
  --ink-2: #5d5f59;
  --ink-3: #6f706a;  /* 4.6:1 on paper: small text stays readable */
  --line: #e6e2da;
  --line-2: #c9c3b7;
  --line-3: #bcb6aa;
  --tint: rgb(27 29 26 / 0.05);
  --accent: #2f5e73;
  --ring: rgb(47 94 115 / 0.2);
  --danger: #a13a2c;
  --danger-bg: #fbeeea;
  --danger-line: #f0d2ca;
  --danger-ring: rgb(161 58 44 / 0.2);
  --success: #3d6a4a;
  --success-bg: #edf4ee;
  --success-line: #d2e4d6;
  --info: #2f5e73;
  --info-bg: #eef3f5;
  --info-line: #d5e2e8;
  --primary: #1b1d1a;
  --primary-ink: #f7f5f1;
  --primary-hover: #33362f;
  --shadow: 0 1px 2px rgb(27 29 26 / 0.05);
  --radius: 12px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

.l-dark {
  --paper: #141513;
  --surface: #1c1d1a;
  --ink: #eeece7;
  --ink-2: #a8a79f;
  --ink-3: #8f8f87;
  --line: #2b2c28;
  --line-2: #46473f;
  --line-3: #52534c;
  --tint: rgb(238 236 231 / 0.06);
  --accent: #8db6c8;
  --ring: rgb(141 182 200 / 0.28);
  --danger: #eba193;
  --danger-bg: #2a1916;
  --danger-line: #4a2a23;
  --danger-ring: rgb(235 161 147 / 0.28);
  --success: #9dc8a7;
  --success-bg: #162219;
  --success-line: #283e2c;
  --info: #8db6c8;
  --info-bg: #151f23;
  --info-line: #263740;
  --primary: #eeece7;
  --primary-ink: #141513;
  --primary-hover: #ffffff;
  --shadow: none;
  color-scheme: dark;
}

/* Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Icons: drawn as masks, so they take the colour of the text around them */
.l-icon {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--l-icon) center / contain no-repeat;
  mask: var(--l-icon) center / contain no-repeat;
}
.l-icon-key { --l-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='15.5' r='4.5'/%3E%3Cpath d='m10.7 12.3 9.3-9.3'/%3E%3Cpath d='m16 7 3 3'/%3E%3Cpath d='m18.5 4.5 2 2'/%3E%3C/svg%3E"); }
.l-icon-check { --l-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.l-icon-mail { --l-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2.5'/%3E%3Cpath d='m3.5 7 8.5 6 8.5-6'/%3E%3C/svg%3E"); }
.l-icon-lock { --l-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4.5' y='10.5' width='15' height='10' rx='2.5'/%3E%3Cpath d='M8 10.5V7.5a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E"); }
.l-icon-phone { --l-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6.5' y='2.5' width='11' height='19' rx='2.5'/%3E%3Cpath d='M11 18h2'/%3E%3C/svg%3E"); }
.l-icon-laptop { --l-icon: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Crect%20x='4'%20y='5'%20width='16'%20height='11'%20rx='2'/%3E%3Cpath%20d='M2%2019h20'/%3E%3C/svg%3E"); }
.l-icon-external { --l-icon: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M14%204h6v6'/%3E%3Cpath%20d='M20%204l-9%209'/%3E%3Cpath%20d='M18%2014v4a2%202%200%200%201-2%202H6a2%202%200%200%201-2-2V8a2%202%200%200%201%202-2h4'/%3E%3C/svg%3E"); }

/* The frame: brand at the top, one column, wider on a big screen ------- */

.l-top { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  max-width: 760px; margin: 0 auto; }
.l-brand { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.l-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-ink);
  font-weight: 600; font-size: 14px; }
.l-main { max-width: 760px; margin: 0 auto; padding: 8px 20px max(48px, env(safe-area-inset-bottom)); display: grid; gap: 20px; }
.l-loading { color: var(--ink-3); padding: 48px 0; text-align: center; }

.l-hero { padding: 20px 0 8px; }
.l-hero h1 { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.l-hero p { margin-top: 6px; color: var(--ink-2); overflow-wrap: anywhere; }

/* Just after making a passkey (an invitation, an email link): what happened, above everything else */
.l-welcome { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--success-line); border-radius: 16px;
  background: var(--success-bg); color: var(--success); }
.l-welcome .l-icon { margin-top: 2px; }
.l-welcome strong { display: block; font-weight: 600; }
.l-welcome span span { color: var(--ink-2); font-size: 14px; }

.l-section { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.l-section-head { margin-bottom: 16px; }
.l-section-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.l-section-head p { margin-top: 2px; color: var(--ink-2); font-size: 14px; text-wrap: pretty; }
.l-empty { color: var(--ink-3); font-size: 14px; padding: 4px 0; }
.l-hint { margin-top: 10px; color: var(--ink-3); font-size: 13px; text-wrap: pretty; }

@media (min-width: 720px) {
  .l-main { gap: 24px; padding-top: 16px; }
  .l-hero { padding: 32px 0 12px; }
  .l-hero h1 { font-size: 36px; }
  .l-section { padding: 28px; border-radius: 20px; }
}

/* Controls -------------------------------------------------------------- */

.l-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: background-color 150ms var(--ease-out), transform 120ms var(--ease-out), border-color 150ms var(--ease-out); }
.l-button:active { transform: scale(0.98); }
.l-button.l-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.l-button.l-small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.l-button.l-danger-fill { background: var(--danger); border-color: var(--danger); color: var(--surface); }
@media (hover: hover) {
  .l-button:hover { border-color: var(--line-3); background: var(--tint); }
  .l-button.l-primary:hover { background: var(--primary-hover); }
  .l-button.l-danger-fill:hover { background: var(--danger); filter: brightness(1.08); }
}
.l-quiet, .l-link { border: 0; background: none; padding: 8px 10px; margin: -8px -10px; border-radius: 8px; color: var(--accent);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.l-quiet.l-danger { color: var(--danger); }
@media (hover: hover) { .l-quiet:hover, .l-link:hover { background: var(--tint); } }
.l-actions { display: grid; gap: 10px; margin-top: 18px; }
@media (min-width: 520px) { .l-actions { display: flex; flex-wrap: wrap; } }
.l-input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--paper);
  font-size: 16px; }  /* 16px: no zoom on focus in iOS Safari */
.l-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

.l-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.l-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; background: var(--tint);
  color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.l-chip-here { background: var(--success-bg); color: var(--success); }

/* Your apps: a tile each, the whole tile the link ------------------------ */

.l-apps { display: grid; gap: 10px; }
@media (min-width: 560px) { .l-apps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.l-apps > li { display: grid; }  /* each tile as tall as the tallest in its row */
.l-app { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; background: var(--paper);
  transition: border-color 150ms var(--ease-out), transform 150ms var(--ease-out), background-color 150ms var(--ease-out); }
a.l-app:active { transform: scale(0.99); }
@media (hover: hover) { a.l-app:hover { border-color: var(--line-3); background: var(--surface); } }
.l-app-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--info-bg);
  color: var(--accent); font-weight: 600; font-size: 17px; }
.l-app-logo { object-fit: cover; background: none; }  /* an icon brings its own background */
.l-app-text { display: grid; min-width: 0; }
.l-app-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.l-app-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.l-app-title .l-chip { flex: none; min-height: 20px; padding: 0 7px; font-size: 11.5px; }
.l-app-host { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-app .l-icon-external { color: var(--ink-3); width: 16px; height: 16px; }

/* Rows: passkeys and devices --------------------------------------------- */

.l-rows > li + li { border-top: 1px solid var(--line); }
.l-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 14px; padding: 14px 0; }
.l-rows > li:first-child { padding-top: 4px; }
.l-row-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--tint); color: var(--ink-2); }
.l-row-text { display: grid; min-width: 0; }
.l-row-title { font-weight: 500; overflow-wrap: anywhere; }
.l-row-meta { color: var(--ink-3); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.l-row-actions { grid-column: 2; display: flex; gap: 18px; align-items: center; margin-top: 4px; }
@media (min-width: 560px) {
  .l-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .l-row-actions { grid-column: 3; margin-top: 0; }
}
.l-inline-form, .l-confirm { grid-column: 1 / -1; display: grid; gap: 12px; }
.l-confirm p { color: var(--ink-2); font-size: 14px; }
.l-inline-form .l-row-actions, .l-confirm .l-row-actions, .l-name-form .l-row-actions { grid-column: auto; margin: 0; }
.l-aside { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--tint);
  color: var(--ink-2); font-size: 14px; }
.l-aside > span:not(.l-icon) { flex: 1; }

/* About you -------------------------------------------------------------- */

.l-facts { display: grid; }
.l-fact { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 12px 0; }
.l-fact + .l-fact { border-top: 1px solid var(--line); }
.l-fact:first-child { padding-top: 0; }
.l-fact dt { grid-column: 1; color: var(--ink-3); font-size: 13px; }
.l-fact dd { grid-column: 1; overflow-wrap: anywhere; }
.l-fact dd small { display: block; color: var(--ink-3); font-size: 13px; }
.l-fact dd .l-chips { margin-top: 4px; }
.l-fact > button { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; }
.l-name-form { display: grid; gap: 12px; }
.l-name-form label { display: grid; gap: 6px; color: var(--ink-2); font-size: 13px; }
@media (min-width: 560px) { .l-name-form { grid-template-columns: 1fr 1fr; } .l-name-form .l-row-actions { grid-column: 1 / -1; } }

/* What happened: a quiet note at the bottom ------------------------------ */

.l-toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px); opacity: 0;
  max-width: calc(100vw - 40px); padding: 11px 16px; border-radius: 12px; background: var(--primary); color: var(--primary-ink);
  font-size: 14px; font-weight: 500; pointer-events: none; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
.l-toast.l-show { opacity: 1; transform: translate(-50%, 0); }
.l-toast.l-bad { background: var(--danger); color: var(--surface); }

/* Arriving: the sections settle in, one after another -------------------- */

.l-ready .l-main > * { animation: l-settle 420ms var(--ease-out) both; }
.l-ready .l-main > :nth-child(2) { animation-delay: 40ms; }
.l-ready .l-main > :nth-child(3) { animation-delay: 80ms; }
.l-ready .l-main > :nth-child(4) { animation-delay: 120ms; }
.l-ready .l-main > :nth-child(5) { animation-delay: 160ms; }
@keyframes l-settle { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .l-ready .l-main > * { animation: none; } .l-toast, .l-button, .l-app { transition: none; } }
