# ==============================================================================
# WFA Outfit & Perspective Conflict Rulesheet (outfit_conflicts.txt)
# ==============================================================================
# Hot-reloads automatically whenever you edit & save this file (no restart needed).
# You can also duplicate this file into new .txt presets inside the `rules/` folder!
#
# QUICK SYNTAX GUIDE:
#   1. Pattern Matching:
#      - Exact tag     : `open shirt`     (matches exact tag, ignores `_` vs space & `(tag:1.2)` weights)
#      - Word match `~`: `~bra`           (matches any tag containing the whole word `bra`, e.g. `white lace bra`,
#                                          NEVER matches `braid`, `bracelet`, `braless`, or `no bra`!)
#      - Wildcard `*`  : `*skirt`         (character wildcard: matches `skirt`, `miniskirt`, `pleated miniskirt`)
#      - Group exclude : `-skirt lift`    (inside `@group`, vetoes non-garment action/modifier tags)
#
#   2. Definitions:
#      @view  <NAME> = pattern1, pattern2, ...      (if none match in prompt, defaults to `FRONT`)
#      @group <NAME> = pattern1, -exclude1, ...     (reusable group of garments or reveal modifiers)
#
#   3. Rules (evaluated in 2 stages — Occlusion FIRST, Combos SECOND!):
#      - Stage 1 (Occlusion & Rewrites):
#          HIDE <targets>                  | WHEN <cond> | VIEW <views> | UNLESS <cond> | +NEG <neg_tags>
#          REPLACE <targets> => <new_tag>  | WHEN <cond> | VIEW <views> | UNLESS <cond> | +NEG <neg_tags>
#      - Stage 2 (Visible-Only Overlaps — runs AFTER Stage 1 so hidden items never trigger combos!):
#          COMBO <itemA> + <itemB> => <combo_tag> | VIEW <views> | UNLESS <cond> | PLACEHOLDER /*...*/
#      - Stage 3 (Conditional Negative Reinforcements):
#          NEG <neg_tags>                  | WHEN <cond> | VIEW <views> | UNLESS <cond>
#
#   4. Condition Logic in `WHEN` and `UNLESS`:
#      - Comma `,` = OR   (e.g. `WHEN TOPS, DRESSES`)
#      - Plus  `+` = AND  (e.g. `UNLESS sitting + ~spread legs`)
#      - Bang  `!` = NOT  (e.g. `VIEW !BACK`)
# ==============================================================================


# ------------------------------------------------------------------------------
# 1. CAMERA PERSPECTIVES (`@view`)
# ------------------------------------------------------------------------------
# Multiple views can be active simultaneously (e.g. `from behind, from below` = BACK + BELOW).
# When no `@view` tag is found in the prompt, `FRONT` is assumed automatically.

@view BACK  = from behind, facing away, facing back, rear view, back view, ass focus
@view BELOW = from below, upskirt, low angle, worm's-eye view
@view ABOVE = from above, high angle, bird's-eye view
@view SIDE  = from side, profile
@view FRONT = from front, straight-on, facing viewer


# ------------------------------------------------------------------------------
# 2. REVEAL / STATE MODIFIERS (`@group`)
# ------------------------------------------------------------------------------
# Front-opening tops/dresses/robes reveal inner chest layers from FRONT / SIDE / ABOVE, NOT from BACK:
@group OPEN_FRONT   = ~open *shirt, ~open *blouse, ~open *dress, ~open *hanfu, ~open *kimono, ~open *yukata, ~open *robe, ~open *haori, ~open *sweater, ~open *cardigan, ~open *jacket, ~open *coat, ~open *blazer, ~open clothes, ~unbuttoned, ~partially unbuttoned, ~unzipped, front zipper, plunging neckline, ~cleavage, ~breasts out, ~breast slip, ~nipple slip, clothes pull, shirt pull, dress pull, hanfu pull, kimono pull, -~unzipped pants, -~unzipped shorts, -~unzipped jeans, -~unzipped skirt, -~unbuttoned pants, -~unbuttoned shorts

# Back-opening garments reveal inner back/straps/wraps from BACK:
@group OPEN_BACK    = ~backless, ~open back, virgin killer sweater

# All-angle upper reveals (visible from FRONT, SIDE, and BACK):
@group TOP_REVEAL   = ~shirt lift, ~sweater lift, ~dress lift, ~hanfu lift, ~kimono lift, ~clothes lift, ~lifting own clothes, ~torn, ~ripped, ~see-through, ~sheer, ~wet shirt, ~wet clothes, ~transparent, ~off shoulder, ~bare shoulders, ~strap slip, ~undressing, ~mirror, ~reflection

# Closed heavy outerwear (hides inner torso layers if neither jacket nor top is open):
@group CLOSED_OUTER = closed jacket, closed coat, closed blazer, closed cardigan, closed haori, closed robe, buttoned coat, zipped jacket

# Skirt / Dress / Hanfu / Qun lower reveals (when panties under a skirt/dress/robe ARE visible):
@group SKIRT_REVEAL = ~skirt lift, ~dress lift, ~hanfu lift, ~aoqun lift, ~qun lift, ~ruqun lift, ~mamianqun lift, ~kimono lift, ~clothes lift, ~lifting own clothes, ~upskirt, ~pantyshot, ~wind lift, ~skirt flip, ~skirt pull, ~skirt tug, ~skirt hold, ~skirt aside, ~dress pull, ~dress tug, ~dress aside, ~hanfu pull, ~hanfu aside, ~aoqun pull, ~aoqun aside, ~qun pull, ~qun aside, ~ruqun pull, ~ruqun aside, ~kimono pull, ~kimono aside, ~panties aside, ~panty pull, ~panties around one leg, ~see-through, ~sheer, ~torn skirt, ~torn dress, ~torn hanfu, ~torn aoqun, ~torn qun, ~torn ruqun, ~torn kimono, ass visible through thighs, ~mirror

# Shorts / Pants lower reveals (when panties under pants/shorts ARE visible):
@group PANTS_REVEAL = ~pants pull, ~shorts pull, ~pants down, ~shorts down, ~pants around one leg, ~shorts around one leg, ~shorts aside, ~pants aside, ~unbuttoned pants, ~unbuttoned shorts, ~unzipped pants, ~unzipped shorts, ~unzipped jeans, ~open belt, ~open fly, ~whale tail, ~panties peek, ~lowleg pants, ~torn pants, ~torn shorts


# ------------------------------------------------------------------------------
# 3. GARMENT LAYER GROUPS (`@group`)
# ------------------------------------------------------------------------------
@group STD_BRAS  = ~bra, ~bikini top, ~bandeau, ~bustier, -~no bra, -~braless
@group SARASHI   = ~chest sarashi, ~sarashi, -~pelvic sarashi, -~no sarashi
@group BRAS      = STD_BRAS, SARASHI

@group TOPS      = ~shirt, ~sweatshirt, ~undershirt, ~overshirt, ~nightshirt, ~blouse, ~sweater, ~turtleneck, ~hoodie, ~jersey, ~camisole, ~tank top, ~crop top, ~tube top, ~vest, ~waistcoat, -~no shirt, -~shirtless, -~shirt lift, -~sweater lift, -~clothes lift, -~shirt pull, -~shirt tug, -~holding shirt, -~shirt dress, -~shirtdress
@group DRESSES   = ~dress, ~sundress, ~minidress, ~microdress, ~shirtdress, ~nightdress, ~gown, ~hanfu, ~kimono, ~yukata, ~cheongsam, ~qipao, ~robe, -~no dress, -~dress lift, -~dress pull, -~dress tug, -~dress aside, -~hanfu lift, -~hanfu pull, -~hanfu aside, -~kimono lift, -~kimono pull, -~kimono aside, -~under dress, -~undressing, -~dress shirt, -~dress pants, -~dress shoes, -~dress straps
@group OUTERWEAR = ~jacket, ~blazer, ~coat, ~cardigan, ~haori, -~no jacket, -~no coat, -~no haori

# Frontal neckwear, collar knots & chest ornaments (hang on the front of the throat/sternum, occluded from BACK):
@group FRONT_NECKWEAR = ~necktie, ~bowtie, ~bow tie, ~ascot, ~cravat, ~jabot, ~bolo tie, ~neckerchief, ~neck ribbon, ~neck bow, ~collar bow, ~collar ribbon, ~chest bow, ~chest ribbon, ~front bow, ~front ribbon, ~bowtie ribbon, ~tie clip, ~tie pin, ~neck bell, ~collar bell, ~brooch, ~chest jewel, ~chest gem, ~chest ornament, ~pendant, ~locket, ~medallion, ~dog tags, ~lanyard, ~name tag, ~id card, ~lapel pin, ~boutonniere, ~breast pocket, ~chest pocket, ~tie, -~hair tie, -~hair ties, -~hair bow, -~hair ribbon, -~back bow, -~back ribbon, -~waist bow, -~waist ribbon, -~hat bow, -~hat ribbon, -~tail bow, -~tail ribbon, -~side-tie, -~side tie, -~front-tie, -~front tie, -~back-tie, -~back tie, -~bikini, -~panties, -~sarong, -~top, -~shirt, -~dress, -~skirt, -~shorts, -~tie-dye, -~tie dye, -~hogtie, -~ankle tie, -~wrist tie

@group PANTIES   = ~panties, ~bikini bottom, ~thong, ~g-string, ~fundoshi, ~pelvic sarashi, ~shimapan, -~no panties, -~pantyless, -~under pantyhose, -~over pantyhose, -~panties aside, -~panty pull, -~panties around one leg
@group LEGWEAR   = ~pantyhose, ~tights, ~bodystocking, -~no pantyhose, -~under pantyhose, -~over pantyhose
@group SKIRTS    = ~skirt, ~miniskirt, ~microskirt, ~overskirt, ~hakama, ~aoqun, ~qun, ~mamianqun, ~ruqun, -~no skirt, -~no hakama, -~no aoqun, -~no qun, -~no mamianqun, -~no ruqun, -~aoqun lift, -~aoqun pull, -~aoqun aside, -~qun lift, -~qun pull, -~qun aside, -~mamianqun lift, -~ruqun lift, -~ruqun pull, -~ruqun aside, -~upskirt, -~skirt lift, -~skirt flip, -~skirt pull, -~skirt tug, -~skirt hold, -~skirt aside, -~under skirt
@group PANTS     = ~pants, ~jeans, ~trousers, ~shorts, ~bloomers, ~leggings, ~bike shorts, -~no pants, -~no shorts, -~under skirt, -~under dress, -~pants pull, -~shorts pull, -~pants down, -~shorts down, -~pants around one leg, -~shorts around one leg, -~shorts aside, -~pants aside


# ------------------------------------------------------------------------------
# 4. FACIAL & EYE OCCLUSION GROUPS (`@group`)
# ------------------------------------------------------------------------------
# Head turned completely away from camera (no face visible):
@group FACING_AWAY        = ~facing away, ~facing back, ~back of head

# Single-eye occlusion triggers (rewrites `<color/style> eyes` => `<color/style> eye`):
@group ONE_EYE_OCCLUDED   = ~eyepatch, ~eye patch, ~one eye covered, ~hair over one eye, ~one eye closed, ~one-eyed, ~flower over eye, ~scar over *eye, ~scar across *eye

# Tags requiring two visible eyes (hidden when one eye is covered by an eyepatch):
@group TWO_EYE_ONLY       = ~heterochromia, ~multicolored eyes, ~uneven eyes, ~mismatched pupils, ~mismatched eyebrows, ~extra eyes, alternate eye color

# Plural `<color/descriptor> eyes` tags that singularize to `<color/descriptor> eye` under `ONE_EYE_OCCLUDED`:
@group EYE_PLURAL         = * eyes, -~closed eyes, -~half-closed eyes, -~narrowed eyes, -~unusually open eyes, -~averting eyes, -~shading eyes, -~covering eyes, -~covered eyes, -~no eyes, -~extra eyes, -~uneven eyes, -~multicolored eyes, -~between eyes, -~over eyes, -~under eyes, -~around eyes, -~across eyes

# Inner-eye details (iris color, pupils, sclera, inner symbols — hidden when `closed eyes` OR `facing away`):
@group EYE_INTERIOR       = EYE_PLURAL, TWO_EYE_ONLY, ~pupils, ~pupil, ~no pupils, ~sclera, ~eyeball, * eye, -~one eye, -~over *eye, -~under *eye, -~across *eye, -~around *eye, -~half-closed eye, -~worm's-eye view, -~bird's-eye view, -~eye level, -~bull's-eye

# Open-eye state/expression tags that conflict with `closed eyes`:
@group OPEN_EYE_CONFLICTS = ~wide-eyed, ~unusually open eyes, ~narrowed eyes, ~half-closed eyes, ~half-closed eye, ~squinting, ~one eye closed, ~wink, ~averting eyes, ~eyes visible through hair, ~blank eyes, ~no eyes, ~crazy eyes, ~upturned eyes, ~tsurime, ~tareme, ~sanpaku, ~eye trail

# All outer eye, eyebrow, eyelash, eyewear, mouth/lips/teeth/tongue, nose, cheek, forehead, facial mark, expression, and front-bang features
# (kept when `closed eyes` from front, hidden when `facing away`):
@group FACE_FEATURES      = OPEN_EYE_CONFLICTS, ONE_EYE_OCCLUDED, ~eyes, ~eye, ~no eyes, ~eyebrows, ~eyebrow, ~no eyebrows, ~furrowed brow, ~eyelashes, ~eyelash, ~eyeliner, ~eyeshadow, ~makeup, ~eyewear, ~glasses, ~sunglasses, ~goggles, ~monocle, ~lips, ~lipgloss, ~lipstick, ~mouth, ~no mouth, ~teeth, ~tooth, ~fangs, ~fang, ~tongue, ~smile, ~smiling, ~grin, ~smirk, ~frown, ~pout, ~blush, ~nosebleed, ~nose, ~no nose, ~nostrils, ~cheek, ~cheeks, ~cheekbones, ~whiskers, ~whisker markings, ~freckles, ~dimples, ~forehead, ~face, ~facial, ~faceless, ~gesugao, ~expressionless, ~masked, ~mask, ~beard, ~mustache, ~goatee, ~mole, ~bangs, ~hair intakes, ~hime cut, ~animal ear fluff, ~oni horns, -~worm's-eye view, -~bird's-eye view, -~eye level, -~bull's-eye, -~mole on breast, -~mole on breasts, -~mole on chest, -~mole on ass, -~mole on thigh, -~mole on back, -~mole on stomach, -~mole on neck, -~mole on shoulder, -~mask on head, -~mask on side, -~unmasked


# ==============================================================================
# STAGE 1: DIRECTIONAL & LAYER OCCLUSION RULES (`HIDE` / `REPLACE`)
# ==============================================================================

# --- A. Upper Body: Bra & Chest Sarashi vs Shirt / Sweater / Dress / Hanfu / Kimono ---
# 1. From BEHIND: An `open shirt` or `open hanfu` front does NOT show the bra or chest sarashi through the back!
#    Hide inner chest layers unless backless (`OPEN_BACK`) or lifted/sheer/off-shoulder (`TOP_REVEAL`), and push matching negatives so LoRAs don't draw straps/wraps over the back.
HIDE STD_BRAS | WHEN TOPS, DRESSES, OUTERWEAR | VIEW BACK | UNLESS OPEN_BACK, TOP_REVEAL | +NEG bra, bra straps
HIDE SARASHI  | WHEN TOPS, DRESSES, OUTERWEAR | VIEW BACK | UNLESS OPEN_BACK, TOP_REVEAL | +NEG sarashi, chest sarashi

# 2. From BEHIND: Clean up front-only torso tags (`open shirt`, `open hanfu`, `cleavage`, `unbuttoned`) so the model doesn't
#    hallucinate a front collar on the spine or twist the character backward when clothed from behind.
REPLACE ~open *shirt, ~unbuttoned *shirt   => shirt   | WHEN TOPS      | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *blouse, ~unbuttoned *blouse => blouse  | WHEN TOPS      | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *dress                       => dress   | WHEN DRESSES   | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *hanfu                       => hanfu   | WHEN DRESSES   | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *kimono                      => kimono  | WHEN DRESSES   | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *yukata                      => yukata  | WHEN DRESSES   | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *robe                        => robe    | WHEN DRESSES   | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *sweater                       => sweater  | WHEN TOPS      | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *vest, ~unbuttoned *vest       => vest     | WHEN TOPS      | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *cardigan, ~unbuttoned *cardigan => cardigan | WHEN OUTERWEAR | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *jacket, ~unbuttoned *jacket   => jacket   | WHEN OUTERWEAR | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *coat, ~unbuttoned *coat       => coat     | WHEN OUTERWEAR | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *blazer, ~unbuttoned *blazer   => blazer   | WHEN OUTERWEAR | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
REPLACE ~open *haori                         => haori    | WHEN OUTERWEAR | VIEW BACK | UNLESS FRONT, SIDE, OPEN_BACK, TOP_REVEAL
HIDE ~cleavage, unbuttoned, partially unbuttoned, open clothes, front zipper, plunging neckline, ~breasts out, ~breast slip, ~nipple slip | WHEN TOPS, DRESSES, OUTERWEAR | VIEW BACK | UNLESS FRONT, SIDE, TOP_REVEAL

# 2b. From BEHIND: Frontal neckwear & chest ornaments (`necktie`, `bowtie`, `ascot`, `neckerchief`, `chest bow`, `brooch`, `pendant`, `lanyard`)
#     hang down the front of the throat/sternum; hiding them on `VIEW BACK` stops models from drawing ties/bows on the spine!
HIDE FRONT_NECKWEAR | VIEW BACK | UNLESS FRONT, SIDE, ~mirror, ~reflection

# 3. From FRONT / SIDE / ABOVE: Hide bra & chest sarashi under a closed top/dress/hanfu unless opened in front (`OPEN_FRONT`) or lifted/sheer (`TOP_REVEAL`).
HIDE BRAS | WHEN TOPS, DRESSES | VIEW !BACK | UNLESS OPEN_FRONT, TOP_REVEAL

# 4. Explicitly closed outerwear hides bra & chest sarashi even from front unless lifted/sheer:
HIDE BRAS | WHEN CLOSED_OUTER | VIEW ANY | UNLESS TOP_REVEAL

# 5. Chest sarashi wraps tightly over the bust, obscuring a regular bra if both situational nodes are left enabled:
HIDE STD_BRAS | WHEN SARASHI | VIEW ANY


# --- B. Lower Body: Panties vs Skirt / Dress / Hanfu / Pants / Shorts ---
# 6. Skirt, Dress, or Hanfu obscures Panties from normal angles unless lifted, viewed from below, upskirt, or seated with spread legs:
HIDE PANTIES | WHEN SKIRTS, DRESSES | VIEW ANY | UNLESS VIEW:BELOW, SKIRT_REVEAL, sitting + ~spread legs, squatting + ~spread legs, all fours + VIEW:BACK, bent over + VIEW:BACK

# 7. Pants / Shorts / Leggings obscure Panties from all angles unless pulled down/aside or peeking:
HIDE PANTIES | WHEN PANTS | VIEW ANY | UNLESS PANTS_REVEAL, unzipped + !OUTERWEAR


# --- C. Facial & Eye Occlusion (`facing away`, `closed eyes`, `eyepatch`) ---
# 8. Facing Away: Head turned away from camera hides all eyes, pupils, eyebrows, eyelashes, eyewear, nose, mouth/lips/teeth, facial marks, and front bangs:
HIDE EYE_INTERIOR, FACE_FEATURES | WHEN FACING_AWAY | VIEW ANY | UNLESS ~looking back, ~looking at viewer, VIEW:SIDE

# 9. Closed Eyes: Both eyelids shut hides all eye colors, pupils, sclera, and open-eye expressions while keeping eyelashes, eyebrows, glasses, and mouth/nose:
HIDE EYE_INTERIOR, OPEN_EYE_CONFLICTS | WHEN ~closed eyes + !~half-closed eyes + !~one eye closed | VIEW ANY

# 10. Eyepatch / One Eye Covered: Hides two-eye-only tags (`heterochromia`) and singularizes `<color> eyes` => `<color> eye` (e.g. `blue eyes` => `blue eye`):
HIDE TWO_EYE_ONLY          | WHEN ONE_EYE_OCCLUDED | VIEW ANY | UNLESS ~closed eyes
REPLACE EYE_PLURAL => * eye | WHEN ONE_EYE_OCCLUDED | VIEW ANY | UNLESS ~closed eyes


# ==============================================================================
# STAGE 2: VISIBLE-ONLY OVERLAPS & SYNERGIES (`COMBO`)
# ==============================================================================
# Evaluated AFTER Stage 1! If `panties` were hidden by a skirt in Rule 5, `PANTIES + LEGWEAR`
# automatically will NOT fire — eliminating the need for separate exclusion (`EX`) nodes!

# 1. Panties + Pantyhose / Tights -> `(panties under pantyhose:1.1)`
COMBO PANTIES + LEGWEAR => (panties under pantyhose:1.1) | UNLESS panties over pantyhose, ~panties around one leg | PLACEHOLDER /*panties under pantyhose, */

# 2. Pants / Shorts + Skirt -> `pants under skirt`
COMBO PANTS + SKIRTS    => pants under skirt             | PLACEHOLDER /*pants under skirt, */

# 3. Pants / Shorts + Dress -> `pants under dress`
COMBO PANTS + DRESSES   => pants under dress             | PLACEHOLDER /*pants under dress, */
