/*
 * Daily Log — application styles (vanilla CSS).
 * Lexxy editor theming lives at the bottom of this file; base Lexxy rules ship in the lexxy gem's stylesheet.
 */

:root {
  --paper:        #faf8f3;
  --surface:      #ffffff;
  --surface-2:    #f4f1ea;
  --ink:          #23251f;
  --ink-soft:     #54564d;
  --muted:        #8c8e82;
  --line:         #e8e3d7;
  --line-strong:  #d9d3c4;
  --accent:       #1f6b53;
  --accent-deep:  #134f3c;
  --accent-tint:  #e9f2ed;
  --danger:       #b4453a;

  --radius:       14px;
  --radius-sm:    10px;
  --shadow-sm:    0 1px 2px rgba(35, 37, 31, 0.04), 0 1px 3px rgba(35, 37, 31, 0.06);
  --shadow-md:    0 6px 24px rgba(35, 37, 31, 0.08), 0 2px 6px rgba(35, 37, 31, 0.05);

  --font-ui:      "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-read:    "Newsreader", Georgia, serif;

  --nav-h:        66px;
  --maxw:         1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 480px at 78% -8%, rgba(31, 107, 83, 0.06), transparent 60%);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Navbar ---------- */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--nav-h);
  padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(250, 248, 243, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-sm);
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

/* ---------- Flash ---------- */

.flash {
  max-width: var(--maxw);
  margin: 16px auto -8px;
  padding: 11px 16px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  border: 1px solid #cfe4d9;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  width: calc(100% - clamp(32px, 8vw, 80px));
}

/* ---------- Page layout ---------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 38px) clamp(16px, 4vw, 40px) 64px;
}

.layout {
  display: flex;
  align-items: flex-start;
  gap: clamp(20px, 3vw, 34px);
}

/* ---------- Sidebar / week nav ---------- */

.sidebar {
  flex: 0 0 286px;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}

.week {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.week__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.week__range {
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

.week__arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.week__arrow:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.week__days {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--ink-soft);
  transition: background 0.14s ease, color 0.14s ease;
}

.day:hover { background: var(--surface-2); color: var(--ink); }

.day__name {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.day__date {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.day__flag {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  flex: 0 0 auto;
}

.day--filled .day__flag { background: var(--accent); }

.day--today .day__name::after {
  content: "Today";
  margin-left: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  vertical-align: middle;
}

.day--selected {
  background: var(--accent-tint);
  border-color: #cfe4d9;
  color: var(--accent-deep);
  box-shadow: inset 3px 0 0 var(--accent);
}

.day--selected .day__name { font-weight: 600; }
.day--selected .day__date { color: var(--accent-deep); }
.day--selected:hover { background: var(--accent-tint); }

.week__today {
  display: block;
  margin-top: 12px;
  padding: 9px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-deep);
  border: 1px dashed #c4ddd1;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.week__today:hover { background: var(--accent-tint); }

/* ---------- Editor ---------- */

.editor {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Fill the viewport below the navbar so the editor + Save button reach the
     bottom of the browser by default. */
  min-height: calc(100dvh - var(--nav-h) - 7rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(22px, 3.4vw, 40px);
}

.entry-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.editor__head {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.editor__eyebrow {
  margin: 0 0 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.editor__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.editor__sub {
  margin: 8px 0 0;
  font-size: 1rem;
  color: var(--ink-soft);
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  vertical-align: middle;
}

.editor__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

/* Read-only rendered entry. Grows to fill the panel so the actions row sits at
   the bottom, mirroring the editor form's flex layout. */
.entry-read {
  flex: 1 1 auto;
  min-height: 0;
}

.entry-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.btn {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover { box-shadow: var(--shadow-md); }

/* ---------- Mobile day dropdown (hidden on desktop) ---------- */

.day-menu { display: none; position: relative; }

.day-menu__summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 62vw;
  padding: 9px 14px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  white-space: nowrap;
}

.day-menu__summary::-webkit-details-marker { display: none; }
.day-menu__label { overflow: hidden; text-overflow: ellipsis; }
.day-menu__chevron { color: var(--muted); transition: transform 0.18s ease; flex: 0 0 auto; }
.day-menu[open] .day-menu__chevron { transform: rotate(180deg); }

.day-menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 88vw);
  z-index: 60;
  animation: menu-in 0.16s ease;
}

.day-menu__panel .week {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .sidebar { display: none; }
  .day-menu { display: block; }
  .layout { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Lexxy editor theming ---------- */

/* Remap Lexxy's design tokens onto the app palette. Lexxy's own rules use
   :where() (zero specificity), so these variable overrides drive both the live
   editor and rendered .lexxy-content without needing per-element overrides. */
:root {
  --lexxy-color-ink:            var(--ink);
  --lexxy-color-ink-medium:     var(--ink-soft);
  --lexxy-color-ink-light:      var(--muted);
  --lexxy-color-ink-lighter:    var(--line-strong);  /* borders / separators */
  --lexxy-color-ink-lightest:   var(--surface-2);    /* button hover */

  --lexxy-color-accent-dark:    var(--accent-deep);
  --lexxy-color-accent-medium:  var(--accent);
  --lexxy-color-accent-light:   #cfe4d9;
  --lexxy-color-accent-lightest: var(--accent-tint); /* active button / selection */

  --lexxy-color-canvas:         var(--surface);
  --lexxy-color-link:           var(--accent-deep);

  --lexxy-font-base:            var(--font-read);
  --lexxy-radius:               7px;
  --lexxy-shadow:               var(--shadow-md);
  --lexxy-focus-ring-color:     var(--accent);
}

/* Let the editor fill the panel like the old Trix one did. */
lexxy-editor {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* A single, clean focus ring on the whole editor (toolbar + content). */
lexxy-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 83, 0.15);
}

.lexxy-editor__content {
  flex: 1 1 auto;
  min-height: 220px;
  font-size: 1.12rem;
}

/* Suppress the inner contenteditable focus box so the editor shows only the
   outer ring above — not a second, square-cornered outline around the text. */
.lexxy-editor__content:focus,
.lexxy-editor__content:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Keep the formatting toolbar in view as the entry grows and the page scrolls. */
lexxy-toolbar {
  position: sticky;
  top: var(--nav-h);
  z-index: 10;
  background: var(--surface);
  border-start-start-radius: inherit;
  border-start-end-radius: inherit;
}

/* Rendered + editing content typography. */
.lexxy-content {
  font-family: var(--font-read);
  line-height: 1.75;
  color: var(--ink);
}

.lexxy-content :is(h1, h2, h3) { font-family: var(--font-display); }

/* ---------- Flash variants ---------- */

.flash--alert {
  background: #fbecea;
  color: var(--danger);
  border-color: #f0cfca;
}

/* ---------- Account menu (navbar) ---------- */

.account { position: relative; }
.account > summary { list-style: none; cursor: pointer; }
.account > summary::-webkit-details-marker { display: none; }

.account__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.account__email {
  margin: 0 0 12px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.account__signout button,
.account__signout {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

.account__signout button:hover { background: var(--paper); }

/* ---------- Auth (sign-in / verify) ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--nav-h) - 80px);
  padding: 40px 20px;
}

.auth__card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.auth__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
}

.auth__lead {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

.auth__form { display: flex; flex-direction: column; gap: 8px; }

.auth__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.auth__input {
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 83, 0.15);
}

.auth__input--code {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth__submit { margin-top: 10px; }

.auth__resend { margin-top: 18px; }

.auth__linkbtn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-deep);
  cursor: pointer;
}

.auth__linkbtn:hover { text-decoration: underline; }

.auth__alt {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth__alt:hover { color: var(--ink-soft); }

/* ---------- Navbar primary links ---------- */

.navbar__left {
  display: inline-flex;
  align-items: center;
  gap: clamp(14px, 3vw, 30px);
  min-width: 0;
}

.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover { background: var(--surface-2); color: var(--ink); }

.nav-link--active {
  color: var(--accent-deep);
  background: var(--accent-tint);
}

/* ---------- Links page ---------- */

.links-page { max-width: 760px; margin: 0 auto; }

.links-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.links-head__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  letter-spacing: -0.02em;
}

.links-head__sub { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.96rem; }

.links-head__add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  flex: 0 0 auto;
}

.links-empty {
  margin: 40px 0;
  text-align: center;
  color: var(--muted);
}

.collections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.collection {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}

.collection__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.collection__title-frame { flex: 1 1 auto; min-width: 0; }

.collection__title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.collection__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.collection__add-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  font-size: 0.85rem;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 8px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background 0.14s ease;
}

.link-row:hover { background: var(--surface-2); }

.link-row__link {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  color: var(--accent-deep);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row__link:hover { text-decoration: underline; }

.link-row__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.link-row:hover .link-row__actions,
.link-row:focus-within .link-row__actions { opacity: 1; }

.link-row--editing {
  display: block;
  background: var(--surface-2);
}

/* Stacked link form: title row, url row, then the buttons — full width so it
   stays usable on narrow screens. */
.link-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

/* turbo-frame defaults to display:inline, which would shrink the stacked form to
   its content width — make the new-link frame fill the card. */
.new-link-frame { display: block; }

/* Override .inline-form__input's `flex: 1 1 160px` (defined later in this file):
   in a column flex that 160px basis becomes the input HEIGHT. The descendant
   selector raises specificity so this wins regardless of source order. */
.link-form .link-form__field {
  flex: 0 0 auto;
  width: 100%;
}

.link-form__actions {
  display: flex;
  gap: 8px;
}

.link-form__error {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

/* ---------- Inline edit forms ---------- */

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.inline-form__input {
  flex: 1 1 160px;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inline-form__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 83, 0.15);
}

.inline-form__input--url { flex: 2 1 220px; }

.btn--sm { padding: 8px 14px; font-size: 0.88rem; }

.btn--ghost {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}

.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--danger {
  color: #fff;
  background: var(--danger);
}

.btn--danger:hover { filter: brightness(0.94); }

/* ---------- Icon buttons & drag handles ---------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn--danger:hover { color: var(--danger); border-color: #f0cfca; background: #fbecea; }

.drag-handle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.drag-handle:active { cursor: grabbing; }

.sortable-ghost { opacity: 0.4; }
.sortable-chosen { background: var(--accent-tint); border-radius: var(--radius-sm); }
.sortable-drag { box-shadow: var(--shadow-md); }

/* ---------- Confirm dialog ---------- */

.confirm-dialog {
  margin: auto;
  max-width: 380px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background: var(--surface);
  color: var(--ink);
}

.confirm-dialog::backdrop { background: rgba(35, 37, 31, 0.32); }

.confirm-dialog__message {
  margin: 0 0 20px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
