/* Continuous table layout. The separate cards use the base styles. */
:root[data-layout="table"] {
  --table-header: color-mix(in srgb, var(--bg) 75%, var(--surface));
  --table-rule: color-mix(in srgb, var(--line) 75%, var(--surface));
  --table-index: color-mix(in srgb, var(--line) 77%, var(--accent));
  --embed-safe-left: var(--safe-left);
  --embed-safe-right: var(--safe-right);
  --table-detail-width: clamp(14px, 20vw - 50px, 24px);
}

:root[data-layout="table"][data-light-mode]:not([data-palette]) {
  --surface: #fffefb;
  --muted: #56685e;
  --ink: #111c17;
  --accent: #1f5c3a;
  --soft: #e3f0e7;
  --line: #d4dcd2;
}

[data-layout="table"][data-custom-border] { --table-rule: var(--line); }

[data-layout="table"][data-embed] .app-shell {
  padding-block: calc(10px + var(--safe-top)) calc(8px + var(--safe-bottom));
  padding-inline: calc(14px + var(--embed-safe-left)) calc(14px + var(--embed-safe-right));
}

[data-layout="table"] :is(#open-course, #open-handicap, #desktop-handicap) {
  --field-background: var(--field-surface);
  border-color: var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 3px #172d2810;
}

[data-layout="table"] :is(#open-handicap, #desktop-handicap) {
  border-color: var(--table-index);
}

[data-layout="table"] :is(#open-handicap:has(.index-placeholder:not([hidden])),
  #desktop-handicap:has(#desktop-handicap-index:placeholder-shown)) {
  --field-background: color-mix(in srgb, var(--field-surface) 94%, var(--accent));
  border-color: var(--accent);
}

[data-layout="table"] .field-caption {
  background: linear-gradient(var(--bg) 50%, var(--field-background) 50%);
  color: var(--muted);
}

[data-layout="table"] :is(#open-handicap, #desktop-handicap) .field-caption { color: var(--accent); }
[data-layout="table"] #desktop-handicap-index { color: var(--ink); }

[data-layout="table"][data-embed] .results-panel { --results-frame-border: 1px; }
[data-layout="table"][data-embed] .tee-results {
  --tee-gap: 0px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--muted));
  --results-frame-radius: var(--row-radius, 16px);
  border-radius: var(--results-frame-radius);
  background: var(--surface);
}

[data-layout="table"][data-embed][data-custom-border] .tee-results { border-color: var(--line); }
[data-layout="table"]:is([data-scroll="page"], [data-auto-height]) .tee-results { overflow: clip; }

[data-layout="table"] .tee-results thead {
  background: var(--table-header);
  color: var(--muted);
  border-bottom: 1px solid var(--table-rule);
  letter-spacing: .055em;
  text-transform: uppercase;
}

[data-layout="table"] .tee-results thead :is(th, td) {
  position: relative;
  color: inherit;
  font-weight: 600;
  border: 0;
}

[data-layout="table"] #tee-rows > tr {
  --row-base: var(--surface);
  --row-paper: var(--row-base);
}

[data-layout="table"][data-rows="striped"] #tee-rows > tr:nth-child(even) {
  --row-base: var(--custom-stripe, color-mix(in srgb, var(--surface), var(--bg) 62%));
}

[data-layout="table"][data-rows="ruled"] #tee-rows > tr {
  --row-base: var(--bg);
}

[data-layout="table"] #tee-rows > tr:focus-within {
  --row-paper: color-mix(in srgb, var(--row-base) 60%, var(--soft));
}

@media (hover: hover) {
  [data-layout="table"] #tee-rows > tr:hover {
    --row-paper: color-mix(in srgb, var(--row-base) 60%, var(--soft));
  }
}

[data-layout="table"] .tee-results #tee-rows > tr > :is(th, td) {
  background: var(--row-paper);
  border: 0;
  border-radius: 0;
}

[data-layout="table"] .tee-results #tee-rows > tr + tr > :is(th, td) {
  border-top: 1px solid var(--table-rule);
}

[data-layout="table"] .tee-results thead th:nth-last-child(2),
[data-layout="table"] .tee-results #tee-rows > tr > td:nth-last-child(2) {
  border-inline-start: 1px solid var(--table-rule);
}

[data-layout="table"] .tee-results thead th:last-child,
[data-layout="table"] .tee-results #tee-rows > tr > td:last-child {
  padding-inline-end: var(--table-detail-width);
  color: var(--accent);
}

[data-layout="table"] .tee-results #tee-rows > tr > td.unavailable { color: var(--muted); }
[data-layout="table"] .tee-info { inline-size: var(--table-detail-width); }
[data-layout="table"] #tee-rows .tee-marker {
  background: var(--tee);
  border: 1px solid color-mix(in srgb, var(--tee) 62%, #637267);
  outline: 0;
  border-radius: 5px;
  box-shadow: 0 2px 3px #172d2818;
}

[data-layout="table"] #toggle-color-mode {
  --layout-icon-fill: var(--surface);
  --layout-icon-line: var(--line);
}

[data-layout="table"] #toggle-color-mode::before { box-shadow: 0 2px 4px #172d280b; }

/* The wide embed follows the proportions of the supplied design. */
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
  [data-layout="table"][data-embed] .app-shell {
    --wide-room: min(var(--embed-room), 36px);
    --wide-edge: calc(14px + var(--wide-room) * .3611);
    --wide-icon: calc(34px + var(--wide-room) * .7222);
    --wide-field: calc(45px + var(--wide-room) * .8);
    --wide-radius: calc(14px + var(--wide-room) * .1944);
    --table-detail-width: calc(25px + var(--wide-room) * .7222);
    padding-block: calc(10px + var(--wide-room) * .2778 + var(--safe-top))
      calc(8px + var(--wide-room) * .25 + var(--safe-bottom));
    padding-inline: calc(var(--wide-edge) + var(--embed-safe-left))
      calc(var(--wide-edge) - var(--wide-room) * .1111 + var(--embed-safe-right));
    grid-template-columns: minmax(0, 1fr) var(--wide-icon);
    gap: calc(8px + var(--wide-room) * .5);
  }

  [data-layout="table"][data-embed] .app-shell .masthead { min-height: var(--wide-icon); }
  [data-layout="table"][data-embed] .app-shell .masthead h1 {
    font-size: calc(14px + var(--wide-room) * .3056);
    letter-spacing: calc(1.9px + var(--wide-room) * .0528);
  }

  [data-layout="table"][data-embed] main { gap: calc(6px + var(--wide-room) * .5); }

  [data-layout="table"][data-embed] .controls {
    --field-action-size: calc(26px + var(--wide-room) * .6111);
    --field-inset: calc(12px + var(--wide-room) * .3333);
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: calc(10px + var(--wide-room) * .3333);
    padding: 0;
    border: 0;
  }

  [data-layout="table"][data-embed] :is(#open-course, #open-handicap, #desktop-handicap) {
    min-height: var(--wide-field);
    max-width: none;
    padding-block: 0;
    border-radius: var(--wide-radius);
  }

  [data-layout="table"][data-embed] #desktop-handicap:not(:focus-within) {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--table-index) 24%, transparent), 0 2px 6px #172d2810;
  }

  [data-layout="table"][data-embed] :is(#desktop-handicap-index, .index-field > #handicap-summary) {
    font-size: calc(23px + var(--wide-room) * .5833);
  }

  [data-layout="table"][data-embed] #desktop-handicap-index {
    height: calc(33px + var(--wide-room) * .3889);
    font-weight: 700;
  }
  [data-layout="table"][data-embed] #desktop-handicap-index:placeholder-shown { font-size: calc(13px + var(--wide-room) * .2222); }

  [data-layout="table"][data-embed] .results-panel {
    --tee-columns: minmax(0, 34fr) minmax(0, 17fr) minmax(0, 12.1fr) minmax(0, 16.1fr) minmax(0, 20.8fr);
    --embed-tee-heading: max(17px, calc(7px + var(--wide-room) * .9167));
    --results-heading-inset: calc(13px + var(--wide-room) * .4722);
  }

  [data-layout="table"][data-embed] .tee-results {
    --results-frame-radius: var(--row-radius, calc(16px + var(--wide-room) * .3056));
    box-shadow: 0 3px 14px #172d2809;
  }

  [data-layout="table"][data-embed] .tee-results thead {
    height: var(--embed-tee-heading);
    font-size: var(--embed-label-size);
  }

  [data-layout="table"][data-embed] .tee-results :is(thead th:first-child, #tee-rows > tr > th) {
    padding-inline-start: var(--results-heading-inset);
  }

  [data-layout="table"][data-embed] .tee-results .tee-name { gap: calc(8px + var(--wide-room) * .3333); }
  [data-layout="table"][data-embed] #tee-rows .tee-marker {
    width: calc(6px + var(--wide-room) * .2222);
    height: calc(24px + var(--wide-room) * .3333);
  }

  [data-layout="table"][data-embed] .app-footer .credit,
  [data-layout="table"][data-embed] .app-footer .credit a { gap: calc(6px + var(--wide-room) * .2778); }
  [data-layout="table"][data-embed] .app-footer .credit { font-size: calc(9px + var(--wide-room) * .1944); }
  [data-layout="table"][data-embed] .app-footer .credit img {
    width: calc(104px + var(--wide-room) * 3.2222);
    max-height: none;
  }

}
