/* Optional pattern workbench for the original class showcases. */
.class-pattern-launch {
  position: fixed;
  right: 20px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid #b3975e;
  background: #fffdf5;
  color: #183560;
  box-shadow: 0 4px 18px #302a2626;
  font: 600 11px / 1.4 var(--display, 'Cinzel', Georgia, serif);
  letter-spacing: .035em;
  cursor: pointer;
}

.class-pattern-launch:hover { background: #f5edda; }

.class-pattern-editor {
  position: fixed;
  top: 145px;
  right: 20px;
  z-index: 80;
  width: 320px;
  max-height: calc(100svh - 165px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 19px;
  border: 1px solid #b3975e;
  background: #fffdf5;
  color: #183560;
  box-shadow: 0 10px 32px #302a262e, inset 0 0 0 3px #f2e8d2;
  font-family: var(--serif, 'Cormorant Garamond', Georgia, serif);
  scrollbar-width: thin;
  scrollbar-color: #b3975e #f2e8d2;
}

.class-pattern-editor[hidden],
.class-pattern-launch[hidden] { display: none !important; }

.class-pattern-editor__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.class-pattern-editor__heading h2 {
  margin: 0;
  font: 500 17px / 1.35 var(--display, 'Cinzel', Georgia, serif);
  color: #183560;
}
.class-pattern-eyebrow { margin: 0 0 5px; color: #916b2d; font: 600 8px / 1.4 var(--display); letter-spacing: .08em; text-transform: uppercase; }
.class-pattern-check { display: flex; align-items: center; gap: 8px; color: #685537; font: 500 16px / 1.3 var(--serif); }
.class-pattern-check input { margin: 0; accent-color: #183560; }
.class-pattern-motion { min-height: 37px; border: 1px solid #b3975e; background: #183560; color: #fff0ce; font: 600 10px / 1.4 var(--display); cursor: pointer; }
.class-pattern-motion:disabled { opacity: .5; cursor: default; }
.class-pattern-status { margin: 12px 0 0; color: #685537; font: 500 14px / 1.35 var(--serif); }

.class-pattern-close {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #cfbc94;
  background: #f7f0e0;
  color: #183560;
  font: 400 23px / 1 var(--serif, 'Cormorant Garamond', Georgia, serif);
  cursor: pointer;
}

.class-pattern-close:hover { background: #ede1c8; }

.class-pattern-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.class-pattern-field {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  color: #685537;
  font: 600 10px / 1.45 var(--display, 'Cinzel', Georgia, serif);
  letter-spacing: .02em;
}

.class-pattern-field--wide { grid-column: 1 / -1; }
.class-pattern-field > span { display: flex; justify-content: space-between; gap: 7px; }
.class-pattern-field output { color: #916b2d; }

.class-pattern-field select {
  width: 100%;
  min-width: 0;
  min-height: 37px;
  padding: 7px 9px;
  border: 1px solid #c9b58c;
  border-radius: 0;
  background: #faf5e9;
  color: #183560;
  font: 500 16px / 1.3 var(--serif, 'Cormorant Garamond', Georgia, serif);
  cursor: pointer;
}

.class-pattern-field input[type='range'] {
  width: 100%;
  min-width: 0;
  margin: 6px 0;
  accent-color: #183560;
  cursor: pointer;
}

.class-pattern-field input[type='checkbox'] { accent-color: #183560; cursor: pointer; }
.class-pattern-field select:disabled,
.class-pattern-field input:disabled { opacity: .55; cursor: default; }

.class-pattern-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid #d8c9aa;
}

.class-pattern-reset,
.class-pattern-library {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 11px;
  border: 1px solid #b3975e;
  font: 600 10px / 1.4 var(--display, 'Cinzel', Georgia, serif);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.class-pattern-reset { background: #f7f0e0; color: #685537; }
.class-pattern-reset:hover { background: #ede1c8; }
.class-pattern-library { background: #183560; color: #fff0ce; }
.class-pattern-library:hover { background: #24487a; }
.class-pattern-note { margin: 13px 0 0; color: #786b55; font: italic 400 16px / 1.35 var(--serif, 'Cormorant Garamond', Georgia, serif); }

.class-pattern-launch:focus-visible,
.class-pattern-editor :focus-visible { outline: 3px solid #a27d3c; outline-offset: 3px; }

/* Pattern layers affect only a motto explicitly enabled by the editor. */
.class-pattern-host { position: relative; isolation: isolate; overflow: hidden; }
.class-pattern-host > :not(.surface-pattern) { position: relative; z-index: 1; }
.class-pattern-host > .surface-pattern {
  position: absolute;
  inset: 1px;
  z-index: 0;
  pointer-events: none;
  opacity: var(--pattern-opacity, .3);
  mask-image: linear-gradient(90deg, transparent, #000 74%);
}

.class-pattern-host > .surface-pattern::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--pattern-ink, #a27d3c);
  image-rendering: pixelated;
  mask-image: var(--tile-url, none);
  mask-size: var(--tile-size, 64px) var(--tile-size, 64px);
  mask-position: right center;
  mask-repeat: repeat;
}

.class-pattern-workbench[data-inverted='true'][data-variant='transparent'] .class-pattern-host > .surface-pattern::before {
  mask-image: linear-gradient(#fff, #fff), var(--tile-url);
  mask-size: 100% 100%, var(--tile-size, 64px) var(--tile-size, 64px);
  mask-position: center, right center;
  mask-repeat: no-repeat, repeat;
  mask-composite: exclude;
}

.class-pattern-workbench:is([data-variant='color'], [data-variant='gray']) .class-pattern-host > .surface-pattern::before {
  background: var(--tile-url) right center / var(--tile-size, 64px) var(--tile-size, 64px) repeat;
  mask-image: none;
}

.class-pattern-workbench[data-fade='false'] .class-pattern-host > .surface-pattern { mask-image: none; }
.class-pattern-host > .surface-pattern canvas { position: absolute; inset: 0; display: block; visibility: hidden; width: 100%; height: 100%; image-rendering: pixelated; }
.class-pattern-host > .surface-pattern.is-rendered canvas { visibility: visible; }
.class-pattern-host > .surface-pattern.is-rendered::before { display: none; }

@media (max-width: 620px) {
  .class-pattern-editor {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: calc(100% - 24px);
    max-height: 70svh;
    padding: 18px;
  }
  .class-pattern-launch { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* Static, full-field banner previews in the pattern picker. */
.class-pattern-picker { --pattern-ink: #876026; }
.class-pattern-picker select[hidden],
.class-pattern-options[hidden] { display: none; }
.class-pattern-options {
  position: relative;
  display: grid;
  gap: 6px;
  grid-auto-rows: 58px;
  max-height: 258px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b3975e #f2e8d2;
  padding: 4px 0;
  border-block: 1px solid #c9b58c;
}
.pattern-banner {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 58px;
  flex: none;
  padding: 5px 7px;
  border: 1px solid #b3975e;
  background: linear-gradient(90deg, #e4cfa4, #f2e2bd);
  box-shadow: inset 0 0 0 3px #fff9e34d;
  color: #183560;
  text-align: left;
  cursor: pointer;
}
.pattern-banner-name {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 25px);
  padding: 2px 5px;
  background: #fffdf5e8;
  font: 500 13px / 1.2 var(--serif, Georgia, serif);
  letter-spacing: 0;
}
.pattern-banner-chevron { position: absolute; right: 9px; top: 14px; font-size: 20px; z-index: 1; }
.pattern-banner[aria-selected='true'] { border-color: #183560; box-shadow: inset 0 0 0 2px #183560; }
.pattern-banner:hover { border-color: #183560; }
.class-pattern-options .pattern-banner:focus-visible { outline-offset: -3px; outline-color: #183560; }
.pattern-banner-texture { position: absolute; inset: 1px; opacity: var(--pattern-opacity, .25); pointer-events: none; }
.pattern-banner[data-pattern=''] .pattern-banner-texture { display: none; }
.pattern-banner-texture::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--pattern-ink);
  mask: var(--tile-url) right center / var(--tile-size) var(--tile-size) repeat;
  image-rendering: pixelated;
}
.class-pattern-picker[data-fade='true'] .pattern-banner-texture { mask-image: linear-gradient(90deg, transparent, #000 74%); }
.class-pattern-picker[data-inverted='true'] .pattern-banner-texture::before {
  mask-image: linear-gradient(#fff, #fff), var(--tile-url);
  mask-size: 100% 100%, var(--tile-size) var(--tile-size);
  mask-position: center, right center;
  mask-repeat: no-repeat, repeat;
  mask-composite: exclude;
}
.class-pattern-picker:is([data-variant='color'], [data-variant='gray']) .pattern-banner-texture::before {
  background: var(--tile-url) right center / var(--tile-size) var(--tile-size) repeat;
  mask: none;
}

/* World-page Dragalia halftone, tinted to the original class rail. */
.class-list .class-choice { isolation: isolate; }
.class-list .class-choice::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #a98240;
  mask: url('assets/world/comic-halftone.svg') right center / 100% auto repeat-y;
  opacity: .10;
}
.class-list .class-choice.is-selected::after { opacity: .18; }
.class-list .class-choice:hover::after { opacity: .16; }
