/* Projects page: « Calendrier » (month, week, agenda on phones) and « Chronologie » (timeline) modes. */

/* ---------- shared: toolbar, legend, milestone shapes */
.cal-bar { gap: .5rem .6rem; }
.cal-bar .seg > button { min-width: 2.4rem; justify-content: center; }
.cal-title { text-transform: none; letter-spacing: 0; font-size: 1.12rem; margin-right: auto; min-width: 0; font-variant-numeric: tabular-nums; }
.cal-tw { color: var(--muted); font-weight: 600; margin-right: .2rem; }
.cal-colorby { display: inline-flex; align-items: center; gap: .4rem; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .3rem .55rem; align-items: center; margin: -.15rem 0 .65rem; font-size: .82rem; }
.cal-legend .chip { font-size: .78rem; }
.cal-lg { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); white-space: nowrap; }
.cal-hint { color: var(--muted); margin-left: auto; font-size: .78rem; }
.cal-shape { display: inline-block; flex: none; width: .6rem; height: .6rem; background: var(--c, var(--text)); }
.cal-shape.slot { --c: var(--text); width: .5rem; height: .5rem; }
.cal-shape.bd { --c: var(--accent); transform: rotate(45deg) scale(.86); }
.cal-shape.due { --c: var(--warn); clip-path: polygon(0 0, 100% 0, 50% 100%); width: .7rem; }

/* ---------- calendar layout */
.cal-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; align-items: start; }
.cal-main.with-tray { grid-template-columns: minmax(0, 1fr) 240px; }

/* events and markers (also inside the « +N autres » popover and the drag ghost) */
.cal-ev, .cal-mk { display: flex; align-items: baseline; gap: .3rem; width: 100%; min-width: 0; min-height: 0; margin: 0; text-align: left; white-space: nowrap; overflow: hidden; cursor: pointer; color: var(--text); line-height: 1.3; }
.cal-ev { padding: .08rem .3rem; border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 17%, var(--surface)); font-size: .8rem; }
.cal-ev:hover { background: color-mix(in srgb, var(--c) 30%, var(--surface)); }
.cal-ev .t { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.cal-ev .lb { font-weight: 700; flex: none; color: color-mix(in srgb, var(--c) 70%, var(--text)); }
.cal-ev .lb::after { content: " ·"; color: var(--muted); font-weight: 400; }
.cal-ev .ti, .cal-mk .ti { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal-ev.cont { border-left-style: dashed; }
.cal-ev.done, .cal-mk.done { opacity: .62; }
.cal-mk { align-items: center; padding: 0 .3rem; border: 1px dashed var(--line); background: var(--surface); font-size: .74rem; color: var(--muted); }
.cal-mk:hover { border-color: var(--c); color: var(--text); background: var(--surface); }
.cal-mk .lb { flex: none; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text); }
.cal-mk .cal-shape { --c: var(--accent); }
.cal-mk.due .cal-shape { --c: var(--warn); }
.cal-mk.late .lb { color: var(--danger); }
.cal-mk.late .cal-shape { --c: var(--danger); }
.cal-ev:focus-visible, .cal-mk:focus-visible { outline-offset: -2px; }

/* month grid */
.cal-month { display: grid; grid-template-columns: 2.1rem repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line-strong); }
.cal-month > * { min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-month > :nth-child(8n) { border-right: 0; }
.cal-month > .last { border-bottom: 0; }
.cal-mh { padding: .3rem .45rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom-color: var(--line-strong); }
.cal-mh.wn { padding: .3rem 0; text-align: center; }
button.cal-wn { font-size: .72rem;  border-width: 0 1px 1px 0; border-color: var(--line); background: var(--surface-2); color: var(--muted); padding: .45rem 0 0; justify-content: center; align-items: flex-start; font-variant-numeric: tabular-nums; min-height: 0; }
button.cal-wn.last { border-bottom-width: 0; }
button.cal-wn:hover { color: var(--accent); background: var(--accent-soft); }
.cal-day { min-height: 7.4rem; padding: .2rem .25rem .3rem; display: flex; flex-direction: column; gap: 2px; }
.cal-day.can-add, .cal-wad.can-add, .cal-wcol.can-add { cursor: pointer; }
.cal-day.we { background: color-mix(in srgb, var(--surface-2) 40%, var(--surface)); }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-dn { color: var(--muted); font-weight: 400; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-dh { display: flex; align-items: center; justify-content: space-between; min-height: 1.45rem; }
.cal-dn { font-size: .84rem; font-weight: 600; padding: .02rem .32rem; font-variant-numeric: tabular-nums; }
.today .cal-dn { background: var(--accent); color: var(--accent-ink); }
button.cal-add { opacity: 0; border: 0; background: none; color: var(--accent); font-weight: 700; padding: 0 .4rem; min-height: 0; line-height: 1.3; }
.cal-day:hover button.cal-add, button.cal-add:focus-visible { opacity: 1; }
button.cal-add:hover { background: var(--accent-soft); }
button.cal-more { border: 0; background: none; color: var(--muted); font-size: .76rem; font-weight: 600; padding: .05rem .3rem; min-height: 0; justify-content: flex-start; }
button.cal-more:hover { color: var(--accent); background: var(--accent-soft); }
.cal-pop { padding: .3rem; display: flex; flex-direction: column; gap: 2px; width: min(320px, 92vw); max-height: 60vh; overflow: auto; }
.cal-pop-h { font-weight: 700; font-size: .85rem; padding: .15rem .2rem .35rem; }

/* week grid: header and all-day row stay on top, hours on the left */
.cal-wscroll { overflow: auto; max-height: max(420px, calc(100vh - 15rem)); border: 1px solid var(--line-strong); background: var(--surface); }
.cal-week { --axis: 3.2rem; --colmin: 0px; min-width: 100%; }
.cal-wrow { display: grid; grid-template-columns: var(--axis) repeat(7, minmax(var(--colmin), 1fr)); }
.cal-whead { position: sticky; top: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.cal-wc { position: sticky; left: 0; z-index: 2; background: var(--surface-2); font-size: .72rem; color: var(--muted); padding: .3rem .25rem; border-right: 1px solid var(--line); font-weight: 600; text-align: center; }
.cal-wc.ad { font-weight: 400; font-size: .68rem; display: flex; align-items: center; justify-content: center; }
.cal-wdh { padding: .3rem .4rem; border-right: 1px solid var(--line); background: var(--surface-2); font-size: .82rem; white-space: nowrap; }
.cal-wdh span { color: var(--muted); }
.cal-wdh b { font-variant-numeric: tabular-nums; padding: 0 .25rem; }
.cal-wdh.today b { background: var(--accent); color: var(--accent-ink); }
.cal-wdh.today span { color: var(--accent); font-weight: 600; }
.cal-wrow.ad { border-top: 1px solid var(--line); }
.cal-wad { min-height: 2rem; padding: 2px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); min-width: 0; }
.cal-wad.today { background: var(--accent-soft); }
.cal-wbody { position: relative; }
.cal-axis { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--line); }
.cal-axis span { position: absolute; right: .3rem; font-size: .7rem; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; }
.cal-wcol { position: relative; border-right: 1px solid var(--line); min-width: 0; background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.cal-wcol.we { background-color: color-mix(in srgb, var(--surface-2) 40%, var(--surface)); }
.cal-wcol.today { background-color: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.cal-ev.cal-blk { position: absolute; flex-direction: column; align-items: stretch; gap: 0; white-space: normal; padding: .1rem .3rem; font-size: .76rem; line-height: 1.2; z-index: 1; box-shadow: 0 0 0 1px var(--surface); }
.cal-ev.cal-blk .ti { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow-wrap: break-word; hyphens: auto; }
.cal-ev.cal-blk .lb::after { content: none; }
.cal-ev.cal-blk.short { flex-direction: row; align-items: baseline; gap: .3rem; white-space: nowrap; }
.cal-ev.cal-blk.short .ti { display: block; text-overflow: ellipsis; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; background: var(--danger); }

/* agenda (month on phones) */
.cal-agenda { background: var(--surface); border: 1px solid var(--line-strong); }
.cal-ag-wk { padding: .25rem .6rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-ag-day { padding: .4rem .6rem .55rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.cal-ag-day.today { box-shadow: inset 4px 0 0 var(--accent); }
.cal-ag-h { display: flex; align-items: center; gap: .45rem; margin-bottom: .1rem; }
.cal-ag-n { font-size: 1.15rem; font-weight: 700; min-width: 1.7rem; font-variant-numeric: tabular-nums; }
.cal-ag-l { color: var(--muted); font-size: .9rem; }
.cal-ag-day.today .cal-ag-n { color: var(--accent); }
.cal-ag-add { margin-left: auto; font-weight: 700; }
.cal-agenda .cal-ev, .cal-agenda .cal-mk { white-space: normal; font-size: .9rem; padding: .3rem .45rem; }
.cal-agenda .cal-mk { font-size: .82rem; }

/* tray of projects without a date */
.cal-tray { background: var(--surface); border: 1px solid var(--line-strong); display: flex; flex-direction: column; max-height: max(360px, calc(100vh - 12rem)); }
.cal-tray-h { display: flex; align-items: center; gap: .45rem; padding: .35rem .3rem .35rem .65rem; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); }
.cal-tray-h b { text-transform: uppercase; font-size: .8rem; letter-spacing: .05em; }
.cal-tray-h button { margin-left: auto; }
.cal-tray-hint { margin: 0; padding: .4rem .65rem; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.cal-tray-list { overflow: auto; }
.cal-tr-it { display: flex; align-items: center; gap: .45rem; width: 100%; min-height: 0; margin: 0; padding: .38rem .55rem; border: 0; border-bottom: 1px solid var(--line); border-left: 3px solid var(--c, var(--muted)); background: var(--surface); color: var(--text); text-align: left; font-size: .84rem; }
.cal-tr-it:hover { background: var(--accent-soft); }
.cal-tr-it .code { font-size: .7rem; color: var(--muted); flex: none; }
.cal-tr-it .ti { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-tr-it.done { color: var(--muted); }

/* drag and drop */
.dg { cursor: grab; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.dragging { opacity: .35; }
.cal-ghost.cal-ghost { position: fixed; z-index: 95; pointer-events: none; overflow: visible; opacity: .95; box-shadow: 0 8px 22px rgba(0, 0, 0, .3); right: auto; bottom: auto; }
.cal-ghost-hint { position: absolute; left: 0; top: calc(100% + 4px); padding: .12rem .4rem; background: var(--text); color: var(--bg); font-size: .75rem; font-weight: 600; white-space: nowrap; text-transform: none; letter-spacing: 0; line-height: 1.3; }
.cal-ghost-hint:empty { display: none; }
body.cal-dragging, body.cal-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.cal [data-drop].over { background-color: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
button.cal-undo { margin-left: .5rem; padding: .1rem .5rem; min-height: 0; border: 1px solid currentColor; background: none; color: inherit; font-weight: 700; font-size: .85rem; }
button.cal-undo:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); }

/* ---------- timeline */
.tl { --tl-lab: 270px; --tl-head: 2.9rem; }
.tl-group { white-space: nowrap; }
.tl-scroll { overflow: auto; max-height: max(380px, calc(100vh - 15rem)); border: 1px solid var(--line-strong); background: var(--surface); position: relative; }
.tl-inner { position: relative; min-width: 100%; }
.tl-head { position: sticky; top: 0; z-index: 6; display: flex; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); }
.tl-corner { position: sticky; left: 0; z-index: 2; flex: none; width: var(--tl-lab); background: var(--surface-2); border-right: 1px solid var(--line-strong); padding: .3rem .6rem; display: flex; align-items: flex-end; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.tl-scale { position: relative; flex: none; height: var(--tl-head); overflow: clip; }
.tl-tier { position: relative; height: 50%; }
.tl-tier + .tl-tier { border-top: 1px solid var(--line); }
.tl-t1, .tl-t2 { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); display: flex; align-items: center; overflow: clip; white-space: nowrap; font-size: .75rem; }
.tl-t1 { font-weight: 700; }
.tl-t1 > span { position: sticky; left: var(--tl-lab); padding: 0 .4rem; }
.tl-t2 { justify-content: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-t2 small { font-size: .66rem; color: var(--muted); }
.tl-t2.today small { color: inherit; }
.tl-t2.we { background: color-mix(in srgb, var(--line) 35%, transparent); }
.tl-t2.today { color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.tl-body { position: relative; }
.tl-grid { position: absolute; top: 0; bottom: 0; left: var(--tl-lab); pointer-events: none; }
.tl-l { position: absolute; top: 0; bottom: 0; width: 1px; background: color-mix(in srgb, var(--line) 55%, transparent); }
.tl-l.s { background: var(--line); }
.tl-we { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); z-index: 3; }
.tl-now.head { z-index: 1; opacity: .8; }
.tl-row { display: flex; position: relative; border-bottom: 1px solid var(--line); }
.tl-row:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.tl-lab { position: sticky; left: 0; z-index: 5; flex: none; width: var(--tl-lab); background: var(--surface); border-right: 1px solid var(--line-strong); display: flex; align-items: stretch; min-width: 0; }
.tl-row:hover .tl-lab { background: var(--accent-soft); }
button.tl-name { flex: 1; min-width: 0; min-height: 0; display: flex; align-items: center; gap: .45rem; border: 0; background: none; padding: 0 .55rem; text-align: left; color: var(--text); font-size: .85rem; }
button.tl-name:hover { background: none; color: var(--accent); }
.tl-name .code { font-size: .7rem; color: var(--muted); flex: none; }
.tl-name .ti { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-name.done .ti { color: var(--muted); }
.tl-row.lane .tl-lab { align-items: flex-start; }
.tl-person { display: flex; align-items: center; gap: .45rem; padding: .45rem .55rem; min-width: 0; width: 100%; font-weight: 600; font-size: .88rem; position: sticky; top: calc(var(--tl-head) + 1px); }
.tl-person .ti { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-person .small { font-weight: 400; margin-left: auto; }
.tl-track { position: relative; flex: none; }
button.tl-bar { position: absolute; z-index: 1; display: flex; align-items: center; min-height: 0; padding: 0 .4rem; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 30%, var(--surface)); color: var(--text); font-size: .74rem; font-weight: 600; line-height: 1; overflow: clip; white-space: nowrap; }
button.tl-bar:hover { background: color-mix(in srgb, var(--c) 45%, var(--surface)); }
button.tl-bar > span { overflow: hidden; text-overflow: ellipsis; position: sticky; left: calc(var(--tl-lab) + 4px); }
button.tl-bar.done { opacity: .55; }
.tl-out { position: absolute; z-index: 1; display: flex; align-items: center; font-size: .74rem; white-space: nowrap; color: var(--text); pointer-events: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.tl-out.done { color: var(--muted); }
.tl-mk { position: absolute; z-index: 2; display: flex; align-items: center; transform: translateX(-50%); cursor: pointer; padding: 0 1px; }
.tl-mk .cal-shape { width: .62rem; height: .62rem; box-shadow: 0 0 0 1.5px var(--surface); }
.tl-mk.slot .cal-shape { width: .5rem; height: .5rem; }
.tl-mk.due .cal-shape { width: .72rem; box-shadow: none; }
.tl-mk.late .cal-shape { --c: var(--danger); }
.tl-span { position: absolute; z-index: 1; height: 4px; background: var(--text); opacity: .55; pointer-events: none; }
.tl-lg-now { display: inline-block; width: 2px; height: .9rem; background: var(--danger); }
.tl-nodate { margin-top: .8rem; background: var(--surface); border: 1px solid var(--line-strong); }
.tl-nodate > summary { padding: .5rem .8rem; cursor: pointer; font-weight: 600; background: var(--surface-2); }
.tl-nodate[open] > summary { border-bottom: 1px solid var(--line-strong); }
.tl-nd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- narrow screens */
@media (max-width: 1100px) {
  .cal-main.with-tray { grid-template-columns: minmax(0, 1fr) 200px; }
}
@media (max-width: 900px) {
  .cal-main.with-tray { grid-template-columns: minmax(0, 1fr); }
  .cal-tray { max-height: 50vh; }
  .cal-hint { margin-left: 0; width: 100%; }
}
@media (max-width: 700px) {
  .cal-bar .cal-title { order: -1; width: 100%; font-size: 1.05rem; }
  .cal-week { --axis: 2.6rem; --colmin: 86px; }
  .cal-wscroll { max-height: 72vh; }
  .cal-ev.cal-blk { font-size: .74rem; }
  .cal-legend .chip { font-size: .74rem; }
  button.cal-add { opacity: 1; }
  .cal-hint { display: none; }
  .tl { --tl-lab: 124px; }
  .tl-name .code, .tl-name .av { display: none; }
  .tl-person .av { display: none; }
  .tl-person { font-size: .82rem; }
  .tl-scroll { max-height: 70vh; }
  .tl-nd-list { grid-template-columns: 1fr; }
  .cal-tr-it, button.tl-name { min-height: 40px; }
}
