/* Application styles */

/*
 * Design tokens. These came from the Tailwind `@theme` block before this app
 * dropped Tailwind. The face itself is served by phaedo-ui's @font-face.
 */
:root {
  --font-sans: "Pixelated MS Sans Serif", Arial, sans-serif;

  --color-gray-400: oklch(70.7% 0.022 261.325);
  --color-gray-700: oklch(37.3% 0.034 259.733);
  --color-blue-600: oklch(54.6% 0.245 262.881);
  --color-red-600: oklch(57.7% 0.245 27.325);
}

/* Field log exposure list */
.exposure-list {
  border-top: 1px solid #808080;
}

.exposure-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #808080;
  font-family: var(--font-sans);
  font-size: 12px;
}

.exposure-row-title {
  font-weight: bold;
  font-size: 14px;
}

.exposure-row-detail {
  color: #444;
}

.exposure-row-right {
  text-align: right;
  white-space: nowrap;
  color: #444;
}

/* Win98-inspired segmented control */
.segmented-control {
  display: flex;
  gap: 1px;
  width: 60%;
  align-self: center;
  font-family: var(--font-sans);
  font-size: 18px;
}

@media (min-width: 640px) {
  .segmented-control {
    font-size: 11px;
  }
}

/* The builder's own radio label: the input, then its words in a <div>. It
   takes the control's size rather than .ui-label's. */
.segmented-control label {
  flex: 1 1 0%;
  justify-content: center;
  font-size: inherit;
  line-height: inherit;
  min-width: 0;
  padding: 4px 16px;
  cursor: pointer;
  background: #c0c0c0;
  color: #222;
  user-select: none;
  text-align: center;
  box-shadow:
    inset 1px 1px #fff,
    inset -1px -1px #000,
    inset 2px 2px #dfdfdf,
    inset -2px -2px #808080;
}

.segmented-control input[type="radio"] {
  appearance: none;
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented-control label:has(input:checked) {
  font-weight: bold;
  box-shadow:
    inset -1px -1px #fff,
    inset 1px 1px #000,
    inset -2px -2px #dfdfdf,
    inset 2px 2px #808080;
  padding: 5px 15px 3px 17px;
}

/* Computation readout */
.computation-readout {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-family: var(--font-sans);
  font-size: 18px;
  padding: 6px 12px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  border-radius: 3px;
}

@media (min-width: 640px) {
  .computation-readout {
    font-size: 11px;
  }
}

/* Custom exposure steppers: override phaedo-ui defaults */
.aperture-stepper .stepper-segment,
.speed-stepper .stepper-segment {
  position: relative !important;
  min-width: 0;
}

/* Aperture stepper overrides */
.aperture-stepper {
  max-width: 14rem;
}

/* Speed stepper overrides */
.speed-stepper {
  max-width: none;
}

.speed-stepper-minute,
.speed-stepper-second {
  flex: none;
  width: 5rem;
}

.speed-stepper-fraction {
  flex: none;
  width: 8.5rem;
}

.speed-stepper-minute .stepper-segment-value,
.speed-stepper-second .stepper-segment-value {
  padding-right: 8px;
}

.speed-stepper .stepper-segment-value small {
  font-size: 0.5em;
  font-weight: normal;
  opacity: 0.6;
  vertical-align: baseline;
}

.speed-stepper-fraction .stepper-segment-value {
  text-align: left;
  padding-left: 8px;
}

.aperture-stepper-whole {
  flex: none;
  width: 10rem;
}

.aperture-stepper-fraction {
  flex: none;
  width: 3.5rem;
}

.aperture-stepper-fraction .stepper-segment-value {
  text-align: left;
  padding-left: 8px;
}

/* Field log tab panel needs flex column for margin-top: auto on save button */
.toolbar-tabs [role="tabpanel"] {
  display: flex;
  flex-direction: column;
}

/* Exposure form buttons */
.save-exposure-btn,
.cancel-exposure-btn {
  display: block;
  width: 100%;
  flex-shrink: 0;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 18px;
  color: #222;
  background: #c0c0c0;
  border: none;
  box-shadow:
    inset 1px 1px #fff,
    inset -1px -1px #000,
    inset 2px 2px #dfdfdf,
    inset -2px -2px #808080;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

/* Side-by-side in the exposure tab button row */
.exposure-actions > .save-exposure-btn,
.exposure-actions > .cancel-exposure-btn {
  flex: 1;
  width: auto;
}

.save-exposure-btn:active,
.cancel-exposure-btn:active {
  box-shadow:
    inset -1px -1px #fff,
    inset 1px 1px #000,
    inset -2px -2px #dfdfdf,
    inset 2px 2px #808080;
  padding: 9px 15px 7px 17px;
}

@media (min-width: 640px) {
  .save-exposure-btn,
  .cancel-exposure-btn {
    font-size: 11px;
  }
}

.computation-readout--error {
  color: #a00;
  font-weight: bold;
}

/* ==========================================================================
   Components that replaced Tailwind utility stacks
   ========================================================================== */

/* form_with style: :bare, so the form itself does not break the parent grid. */
.bare-form {
  display: contents;
}

/* --- Field log: exposure index ------------------------------------------ */

.exposure-index {
  margin: 0.75rem;
}

.exposure-index-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.exposure-index-title {
  font-size: 1.125rem;
  line-height: calc(1.75 / 1.125);
  font-weight: 700;
}

@media (min-width: 640px) {
  .exposure-index-title {
    font-size: 0.875rem;
    line-height: calc(1.25 / 0.875);
  }
}

/* --- Field log: shell ---------------------------------------------------- */

.field-log-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #c0c0c0;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: calc(1.25 / 0.875);
  padding-bottom: env(safe-area-inset-bottom);
}

.field-log-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #000080;
  color: #fff;
  padding: 0.5rem 0.75rem;
  padding-top: env(safe-area-inset-top);
}

.field-log-title {
  font-size: 1.125rem;
  line-height: calc(1.75 / 1.125);
  font-weight: 700;
  letter-spacing: 0.025em;
}

@media (min-width: 640px) {
  .field-log-title {
    font-size: 0.875rem;
    line-height: calc(1.25 / 0.875);
  }
}

.field-log-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* --- Field log: exposure form -------------------------------------------- */

.exposure-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.exposure-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.stepper-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.exposure-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

/* A lone cancel button still needs pushing to the bottom of its panel. */
.cancel-exposure-btn--footer {
  margin-top: auto;
}

/* --- Photo catalog: grid -------------------------------------------------- */

.photo-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.photo-grid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.photo-tile {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: hidden;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
}

.photo-tile-actions {
  position: absolute;
  top: 0.25rem;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
}

.photo-tile-link {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.photo-tile-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.photo-tile-placeholder {
  color: var(--color-gray-400);
}

.photo-tile-caption {
  position: absolute;
  bottom: 0.25rem;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-gray-700);
}

.photo-tile-caption--left {
  left: 0.5rem;
}

.photo-tile-caption--right {
  right: 0.5rem;
}

/* --- Photo catalog: sort form --------------------------------------------- */

.sort-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sort-form-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sort-form-option {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sort-form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Each select's field, in place of the 20rem that .ui-field-control gives a
   field in a form's column. */
.sort-form-control {
  width: 12.5rem;
}

/* --- Photo catalog: show -------------------------------------------------- */

.photo-show {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .photo-show {
    grid-template-columns: auto 1fr;
  }
}

.photo-show-image {
  width: 500px;
}

.photo-show-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.photo-show-thumb {
  height: 200px;
  max-width: 24rem;
}

.import-thumb-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

/* --- Photo catalog: capture sequence number ------------------------------- */

.sequence-number-field {
  position: relative;
  width: fit-content;
}

.sequence-number-control {
  width: 4rem;
}

.sequence-number-input {
  text-align: center;
  appearance: textfield;
}

.sequence-number-input::-webkit-outer-spin-button,
.sequence-number-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.sequence-number-note {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0.5rem;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--color-blue-600);
}

.sequence-number-note--error {
  color: var(--color-red-600);
}

/* --- Photo mat: chart and analysis pages ---------------------------------- */

.chart-layout {
  display: grid;
  grid-template-columns: 1fr auto;
}

.chart-sidebar {
  width: 10rem;
  padding: 0.5rem;
}

.chart-sidebar--narrow {
  width: 9rem;
  padding: 0.5rem 0 0.5rem 0.5rem;
}

.chart-label {
  font-size: 0.75rem;
  line-height: calc(1 / 0.75);
  margin-bottom: 0.25rem;
}

.chart-label--spaced {
  margin-top: 0.5rem;
}

.chart-option {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: calc(1 / 0.75);
}

.chart-option--spaced {
  margin-bottom: 0.25rem;
}

.chart-option--spaced-lg {
  margin-bottom: 0.5rem;
}

.chart-group {
  margin-top: 0.5rem;
}

.chart-input {
  padding: 0.125rem 0.25rem;
}

.chart-input--tight {
  padding: 0.125rem;
}

.chart-submit {
  width: 100%;
  margin-top: 0.5rem;
}

/* Win98-inset select, greyed out when the chart it applies to is not shown. */
.chart-select {
  width: 100%;
  padding: 0.125rem 0.25rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: calc(1 / 0.75);
  background: #fff;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
}

.chart-select:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.chart-select--disabled {
  background: #c0c0c0;
  color: #808080;
}

/* --- Photo mat: data grids ------------------------------------------------ */

.data-grid--fill {
  width: 100%;
  height: 100%;
}

.data-grid--spaced {
  margin-top: 1rem;
}

.data-grid--narrow {
  max-width: 20rem;
}

.data-grid-row-alt {
  background: #e0e0e0;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* --- Misc ----------------------------------------------------------------- */

.stacked-grid {
  display: grid;
  gap: 0.5rem;
}

.postable-meta {
  font-size: 0.875rem;
  line-height: calc(1.25 / 0.875);
}

.postable-title {
  font-weight: 700;
}
