/* TinyTools — components.css
   Buttons, chips, cards, forms, toasts, search dialog. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--accent-line); background: var(--accent-soft); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 0 transparent; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.07); box-shadow: 0 0 22px -6px var(--accent-line); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------- Chips (category filters, mode selectors) ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 16px;
  font: inherit; font-size: 0.92rem; font-weight: 550;
  color: var(--text-2);
  background: var(--glass);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.chip:hover { color: var(--text); border-color: var(--accent-line); }
.chip[aria-pressed="true"] { color: var(--text); background: var(--accent-soft); border-color: var(--accent); font-weight: 650; }
.chip .chip-check { display: none; width: 1em; height: 1em; color: var(--accent-text); }
.chip[aria-pressed="true"] .chip-check { display: inline-block; }
.chip .count { font-family: var(--mono); font-size: 0.78rem; color: var(--text-2); }

/* ---------- Tool cards ---------- */
.tool-grid { display: grid; grid-template-columns: 1fr; gap: 14px; list-style: none; margin: 0; padding: 0; }
.tool-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  height: 100%;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.25s;
}
.tool-card::before { /* thin illuminated top border */
  content: ""; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  opacity: 0; transition: opacity 0.25s;
}
@media (hover: hover) {
  .tool-card:hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow); }
  .tool-card:hover::before { opacity: 1; }
}
.tool-card:focus-within { border-color: var(--accent); }
.tool-card:focus-within::before { opacity: 1; }
.tool-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tool-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; flex: none;
  border-radius: 13px;
  color: var(--accent-text);
  background: linear-gradient(145deg, var(--accent-soft), var(--violet-soft));
  border: 1px solid var(--border);
}
.tool-icon .icon { width: 26px; height: 26px; }
.badge { display: inline-flex; align-items: center; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--accent-text); border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 999px; align-self: flex-start; }
.badge-violet { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 50%, transparent); background: var(--violet-soft); }
.tool-card h3 { margin: 4px 0 0; font-size: 1.15rem; }
.tool-card p { margin: 0; color: var(--text-2); font-size: 0.95rem; flex: 1; }
.tool-card .open-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; color: var(--accent-text); min-height: 44px; margin-top: 2px; }
.tool-card .open-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); } /* whole card clickable */
.tool-card .open-link:focus-visible { outline: none; }
.tool-card:has(.open-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.tool-card .open-link .icon { transition: transform 0.2s var(--ease); }
@media (hover: hover) { .tool-card:hover .open-link .icon { transform: translateX(3px); } }
.fav-btn { position: relative; z-index: 2; flex: none; margin: -6px -8px 0 0; }
.fav-btn .icon { width: 22px; height: 22px; }
.fav-btn .icon-star-on { display: none; }
.fav-btn[aria-pressed="true"] { color: var(--accent-2); }
.fav-btn[aria-pressed="true"] .icon-star-on { display: inline-block; }
.fav-btn[aria-pressed="true"] .icon-star-off { display: none; }

.tool-card.is-compact { padding: 16px; }
.tool-card.is-compact .tool-icon { width: 40px; height: 40px; }

/* No results / empty state */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--glass);
  color: var(--text-2);
}
.empty-state .icon { width: 32px; height: 32px; color: var(--accent-text); margin-bottom: 8px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; overflow-wrap: anywhere; }
.empty-state p { margin: 0 auto 16px; max-width: 44ch; }
.result-count { color: var(--text-2); font-size: 0.9rem; margin: 0 0 12px; min-height: 1.4em; }

/* Recently used */
.recent-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.recent-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.recent-link { display: inline-flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 16px 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); text-decoration: none; font-weight: 550; transition: border-color 0.15s, background-color 0.15s; }
.recent-link:hover { border-color: var(--accent-line); background: var(--accent-soft); text-decoration: none; }
.recent-link .tool-icon { width: 30px; height: 30px; border-radius: 9px; }
.recent-link .tool-icon .icon { width: 18px; height: 18px; }

/* ---------- Feature / step cards ---------- */
.feature-grid { display: grid; gap: 14px; grid-template-columns: 1fr; list-style: none; margin: 0; padding: 0; }
.feature { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--glass); }
.feature .tool-icon { margin-bottom: 12px; }
.feature h3 { margin-bottom: 6px; }
.feature p { margin: 0; color: var(--text-2); }
.steps { counter-reset: step; }
.step { position: relative; padding-top: 22px; }
.step::before { counter-increment: step; content: "0" counter(step); font-family: var(--mono); font-size: 0.85rem; font-weight: 600; color: var(--accent-text); position: absolute; top: 20px; right: 20px; }

/* ---------- Breadcrumbs ---------- */
.breadcrumb { margin: 0 0 14px; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin: 0; padding: 0; font-size: 0.9rem; color: var(--text-2); }
.breadcrumb li { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 4px; color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-text); text-decoration: underline; }
.breadcrumb .icon { width: 14px; height: 14px; opacity: 0.7; }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label, .field-label, legend.field-label { font-weight: 600; font-size: 0.92rem; color: var(--text); padding: 0; }
.field-label .opt { color: var(--text-2); font-weight: 400; }
.input, .textarea, .select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.2s;
}
.input, .select { min-height: 48px; padding: 0 14px; }
.textarea { padding: 14px; resize: vertical; line-height: 1.6; min-height: 180px; }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa9c2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.input::placeholder, .textarea::placeholder { color: var(--text-2); opacity: 0.85; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--accent-line); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-soft); }
.hint { color: var(--text-2); font-size: 0.85rem; margin: 0; }
.error-text { display: flex; align-items: flex-start; gap: 7px; color: var(--error); font-size: 0.9rem; font-weight: 550; margin: 0; }
.error-text .icon { margin-top: 2px; width: 1.1em; height: 1.1em; }
.error-text:empty { display: none; }
fieldset { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; }

/* Segmented radio group — real radios, visually restyled */
.seg-group { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.seg label {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-2);
  font-weight: 550; font-size: 0.95rem;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  pointer-events: none;
}
.seg input:hover + label { border-color: var(--accent-line); color: var(--text); }
.seg input:checked + label { color: var(--text); background: var(--accent-soft); border-color: var(--accent); font-weight: 650; }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 3px; }
.seg .seg-check { display: none; width: 1em; height: 1em; color: var(--accent-text); }
.seg input:checked + label .seg-check { display: inline-block; }

/* Checkbox rows */
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.check:hover { color: var(--text); }
.check .sample { margin-left: auto; font-family: var(--mono); font-size: 0.8rem; color: var(--text-2); }

/* Range slider */
.range { width: 100%; height: 44px; background: transparent; accent-color: var(--accent); cursor: pointer; margin: 0; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: var(--border-strong); }
.range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--border-strong); }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent), 0 0 14px -2px var(--accent-line); }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); }
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-inline: 16px; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 10px; max-width: 480px; padding: 12px 16px; background: var(--glass-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); font-size: 0.93rem; font-weight: 550; pointer-events: auto; }
.toast .icon { width: 1.3em; height: 1.3em; }
.toast-success { border-color: var(--success); } .toast-success .icon { color: var(--success); }
.toast-error { border-color: var(--error); } .toast-error .icon { color: var(--error); }
.toast-info .icon { color: var(--accent-text); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: tt-rise 0.25s var(--ease) both; }
}

/* ---------- Header search dialog ---------- */
.search-dialog { width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - 24px)); margin: 12px auto auto; padding: 0; color: var(--text); background: var(--glass-solid); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); overflow: hidden; }
.search-dialog::backdrop { background: rgba(4, 7, 14, 0.7); }
.search-dialog[open] { display: flex; flex-direction: column; }
.sd-form { position: relative; padding: 12px; border-bottom: 1px solid var(--border); }
.sd-form .search-input { height: 52px; border-radius: 12px; }
.sd-close { position: absolute; right: 18px; top: 18px; }
.sd-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.sd-link { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border-radius: 12px; color: var(--text); text-decoration: none; border: 1px solid transparent; }
.sd-link:hover, .sd-link:focus-visible { background: var(--accent-soft); border-color: var(--accent-line); text-decoration: none; outline: none; }
.sd-link .tool-icon { width: 38px; height: 38px; border-radius: 10px; }
.sd-link .tool-icon .icon { width: 21px; height: 21px; }
.sd-name { font-weight: 600; display: block; }
.sd-desc { color: var(--text-2); font-size: 0.85rem; display: block; line-height: 1.35; }
.sd-empty { padding: 24px 16px; text-align: center; color: var(--text-2); margin: 0; }
.sd-hint { margin: 0; padding: 8px 16px 12px; font-size: 0.8rem; color: var(--text-2); }

.recent { margin-bottom: 22px; }
.recent .panel-title { margin-bottom: 10px; }
.editor-head h2 { margin: 0; }

/* ---------- A Thought from the Creator (result-area note) ---------- */
.creator-note { margin: 16px 0 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent-2); }
.creator-note-text { margin: 0; font-size: 0.95rem; line-height: 1.55; font-style: italic; color: var(--text-2); overflow-wrap: anywhere; }
.creator-note-sign { margin: 6px 0 0; font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.02em; color: var(--text-2); }
@media (prefers-reduced-motion: no-preference) {
  .creator-note.is-new { animation: tt-fade 0.5s var(--ease) both; }
}
@keyframes tt-fade { from { opacity: 0; } to { opacity: 1; } }

/* Homepage "What's next?" card (replaces an inline style, which the site's CSP forbids) */
.next-card { max-width: 760px; display: grid; gap: 10px; justify-items: start; }
.next-card h3, .next-card p { margin: 0; }
.next-card .open-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; color: var(--accent-text); min-height: 44px; }
.next-card .open-link:hover { text-decoration: underline; }

/* ---------- Account link in the header (icon only on phones/tablets, icon + label on wide screens) ---------- */
.account-link .account-label { display: none; }
.account-link[aria-current="page"] { color: var(--text); background: var(--accent-soft); border-color: var(--accent-line); }
@media (min-width: 960px) {
  .account-link { width: auto; padding: 0 14px; gap: 8px; border-color: var(--border); }
  .account-link .account-label { display: inline; font-size: 0.9rem; font-weight: 550; }
}
